Skip to content

Commit

Permalink
crypto: add p256 sig
Browse files Browse the repository at this point in the history
  • Loading branch information
emturner committed Dec 18, 2023
1 parent c46fc5e commit 03a1693
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crypto/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mod prefix_bytes {
pub const GENERIC_SIGNATURE_HASH: [u8; 3] = [4, 130, 43];
pub const ED22519_SIGNATURE_HASH: [u8; 5] = [9, 245, 205, 134, 18];
pub const SECP256K1_SIGNATURE_HASH: [u8; 5] = [13, 115, 101, 19, 63];
pub const P256_SIGNATURE_HASH: [u8; 4] = [54, 240, 44, 52];
pub const BLS_SIGNATURE_HASH: [u8; 4] = [40, 171, 64, 207];
pub const NONCE_HASH: [u8; 3] = [69, 220, 169];
pub const OPERATION_LIST_HASH: [u8; 2] = [133, 233];
Expand Down Expand Up @@ -310,6 +311,7 @@ define_hash!(SecretKeyBls);
define_hash!(Signature);
define_hash!(Ed25519Signature);
define_hash!(Secp256k1Signature);
define_hash!(P256Signature);
define_hash!(BlsSignature);
define_hash!(NonceHash);
define_hash!(OperationListHash);
Expand Down Expand Up @@ -370,6 +372,8 @@ pub enum HashType {
Ed25519Signature,
// "\013\115\101\019\063" (* spsig1(99) *)
Secp256k1Signature,
// "\054\240\044\052" (* p2sig(98) *)
P256Signature,
// "\040\171\064\207" (* BLsig(142) *)
BlsSignature,
// "\069\220\169" (* nce(53) *)
Expand Down Expand Up @@ -411,6 +415,7 @@ impl HashType {
HashType::Signature => &GENERIC_SIGNATURE_HASH,
HashType::Ed25519Signature => &ED22519_SIGNATURE_HASH,
HashType::Secp256k1Signature => &SECP256K1_SIGNATURE_HASH,
HashType::P256Signature => &P256_SIGNATURE_HASH,
HashType::BlsSignature => &BLS_SIGNATURE_HASH,
HashType::NonceHash => &NONCE_HASH,
HashType::OperationListHash => &OPERATION_LIST_HASH,
Expand Down Expand Up @@ -447,6 +452,7 @@ impl HashType {
HashType::SecretKeyEd25519
| HashType::Ed25519Signature
| HashType::Secp256k1Signature
| HashType::P256Signature
| HashType::Signature => 64,
HashType::BlsSignature => 96,
}
Expand Down Expand Up @@ -1287,6 +1293,12 @@ mod tests {
["spsig1PPUFZucuAQybs5wsqsNQ68QNgFaBnVKMFaoZZfi1BtNnuCAWnmL9wVy5HfHkR6AeodjVGxpBVVSYcJKyMURn6K1yknYLm"]
);

test!(
sig_p256,
P256Signature,
["p2sigRmXDp38VNVaEQH28LYukfLPn8QB5hPEberhvQrrUpRscDZJrrApbRh2u46PTVTwKXjxTLKNN9dyLhPQU6U6jWPGxe4d9v"]
);

test!(generic_sig, Signature, ["sigNCaj9CnmD94eZH9C7aPPqBbVCJF72fYmCFAXqEbWfqE633WNFWYQJFnDUFgRUQXR8fQ5tKSfJeTe6UAi75eTzzQf7AEc1"]);

test!(
Expand Down
1 change: 1 addition & 0 deletions tezos-encoding/src/enc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ encode_hash!(crypto::hash::SecretKeyBls);
encode_hash!(crypto::hash::Signature);
encode_hash!(crypto::hash::Ed25519Signature);
encode_hash!(crypto::hash::Secp256k1Signature);
encode_hash!(crypto::hash::P256Signature);
encode_hash!(crypto::hash::BlsSignature);
encode_hash!(crypto::hash::NonceHash);
encode_hash!(crypto::hash::SmartRollupHash);
Expand Down
1 change: 1 addition & 0 deletions tezos-encoding/src/nom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ hash_nom_reader!(SecretKeyBls);
hash_nom_reader!(Signature);
hash_nom_reader!(Ed25519Signature);
hash_nom_reader!(Secp256k1Signature);
hash_nom_reader!(P256Signature);
hash_nom_reader!(BlsSignature);
hash_nom_reader!(NonceHash);
hash_nom_reader!(SmartRollupHash);
Expand Down

0 comments on commit 03a1693

Please sign in to comment.