Public Key plain byte encoding (#540)
* public key is encoded in bytes * ECDSA pubkey in uncompressed format
This commit is contained in:
@@ -16,9 +16,8 @@ use super::exponent256::ExponentP256;
|
||||
use super::gfp256::GFP256;
|
||||
use super::int256::Int256;
|
||||
use super::montgomery::Montgomery;
|
||||
#[cfg(test)]
|
||||
use arrayref::array_mut_ref;
|
||||
#[cfg(feature = "std")]
|
||||
use arrayref::array_mut_ref;
|
||||
use arrayref::array_ref;
|
||||
use core::ops::Add;
|
||||
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq};
|
||||
@@ -45,7 +44,6 @@ impl PointP256 {
|
||||
/** Serialization **/
|
||||
// This uses uncompressed point format from "SEC 1: Elliptic Curve Cryptography" ("Standards for
|
||||
// Efficient Cryptography").
|
||||
#[cfg(feature = "std")]
|
||||
pub fn from_bytes_uncompressed_vartime(bytes: &[u8]) -> Option<PointP256> {
|
||||
if bytes.len() != 65 || bytes[0] != 0x04 {
|
||||
None
|
||||
@@ -57,7 +55,7 @@ impl PointP256 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(feature = "std")]
|
||||
pub fn to_bytes_uncompressed(&self, bytes: &mut [u8; 65]) {
|
||||
bytes[0] = 0x04;
|
||||
self.x.to_int().to_bin(array_mut_ref![bytes, 1, 32]);
|
||||
|
||||
@@ -231,13 +231,12 @@ impl PubKey {
|
||||
.map(|p| PubKey { p })
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub fn from_bytes_uncompressed(bytes: &[u8]) -> Option<PubKey> {
|
||||
PointP256::from_bytes_uncompressed_vartime(bytes).map(|p| PubKey { p })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn to_bytes_uncompressed(&self, bytes: &mut [u8; 65]) {
|
||||
#[cfg(feature = "std")]
|
||||
pub fn to_bytes_uncompressed(&self, bytes: &mut [u8; 65]) {
|
||||
self.p.to_bytes_uncompressed(bytes);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user