mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-05-14 12:09:35 +00:00
Revert "Removed privacy keycard calls"
This reverts commit d70ef505a1f40b87159099761f5fce5a31e3f17b.
This commit is contained in:
parent
d70ef505a1
commit
e319c8fa55
@ -85,15 +85,8 @@ impl HashableBlockData {
|
|||||||
signing_key: &nssa::PrivateKey,
|
signing_key: &nssa::PrivateKey,
|
||||||
bedrock_parent_id: MantleMsgId,
|
bedrock_parent_id: MantleMsgId,
|
||||||
) -> Block {
|
) -> Block {
|
||||||
const PREFIX: &[u8; 32] =
|
|
||||||
b"/LEE/v0.3/Message/Block/\x00\x00\x00\x00\x00\x00\x00\x00";
|
|
||||||
|
|
||||||
let data_bytes = borsh::to_vec(&self).unwrap();
|
let data_bytes = borsh::to_vec(&self).unwrap();
|
||||||
let mut bytes = Vec::with_capacity(PREFIX.len() + data_bytes.len());
|
let hash = OwnHasher::hash(&data_bytes);
|
||||||
bytes.extend_from_slice(PREFIX);
|
|
||||||
bytes.extend_from_slice(&data_bytes);
|
|
||||||
|
|
||||||
let hash = OwnHasher::hash(&bytes);
|
|
||||||
let signature = nssa::Signature::new(signing_key, &hash.0);
|
let signature = nssa::Signature::new(signing_key, &hash.0);
|
||||||
Block {
|
Block {
|
||||||
header: BlockHeader {
|
header: BlockHeader {
|
||||||
|
|||||||
@ -121,14 +121,7 @@ impl Message {
|
|||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn hash_message(&self) -> [u8; 32] {
|
pub fn hash_message(&self) -> [u8; 32] {
|
||||||
const PREFIX: &[u8; 32] =
|
Sha256::digest(self.to_bytes()).into()
|
||||||
b"/LEE/v0.3/Message/Privacy/\x00\x00\x00\x00\x00\x00";
|
|
||||||
|
|
||||||
let mut bytes = Vec::with_capacity(PREFIX.len() + self.to_bytes().len());
|
|
||||||
bytes.extend_from_slice(PREFIX);
|
|
||||||
bytes.extend_from_slice(&self.to_bytes());
|
|
||||||
|
|
||||||
Sha256::digest(bytes).into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -67,13 +67,6 @@ impl Message {
|
|||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn hash_message(&self) -> [u8; 32] {
|
pub fn hash_message(&self) -> [u8; 32] {
|
||||||
const PREFIX: &[u8; 32] =
|
Sha256::digest(self.to_bytes()).into()
|
||||||
b"/LEE/v0.3/Message/Public/\x00\x00\x00\x00\x00\x00\x00";
|
|
||||||
|
|
||||||
let mut bytes = Vec::with_capacity(PREFIX.len() + self.to_bytes().len());
|
|
||||||
bytes.extend_from_slice(PREFIX);
|
|
||||||
bytes.extend_from_slice(&self.to_bytes());
|
|
||||||
|
|
||||||
Sha256::digest(bytes).into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ pub struct TestVector {
|
|||||||
pub seckey: Option<PrivateKey>,
|
pub seckey: Option<PrivateKey>,
|
||||||
pub pubkey: PublicKey,
|
pub pubkey: PublicKey,
|
||||||
pub aux_rand: Option<[u8; 32]>,
|
pub aux_rand: Option<[u8; 32]>,
|
||||||
pub message: [u8; 32],
|
pub message: Option<[u8; 32]>,
|
||||||
pub signature: Signature,
|
pub signature: Signature,
|
||||||
pub verification_result: bool,
|
pub verification_result: bool,
|
||||||
}
|
}
|
||||||
@ -28,9 +28,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
aux_rand: Some(hex_to_bytes::<32>(
|
aux_rand: Some(hex_to_bytes::<32>(
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000",
|
"0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
)),
|
)),
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000",
|
"0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"E907831F80848D1069A5371B402410364BDF1C5F8307B0084C55F1CE2DCA821525F66A4A85EA8B71E482A74F382D2CE5EBEEE8FDB2172F477DF4900D310536C0",
|
"E907831F80848D1069A5371B402410364BDF1C5F8307B0084C55F1CE2DCA821525F66A4A85EA8B71E482A74F382D2CE5EBEEE8FDB2172F477DF4900D310536C0",
|
||||||
@ -52,9 +52,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
aux_rand: Some(hex_to_bytes::<32>(
|
aux_rand: Some(hex_to_bytes::<32>(
|
||||||
"0000000000000000000000000000000000000000000000000000000000000001",
|
"0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
)),
|
)),
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"6896BD60EEAE296DB48A229FF71DFE071BDE413E6D43F917DC8DCF8C78DE33418906D11AC976ABCCB20B091292BFF4EA897EFCB639EA871CFA95F6DE339E4B0A",
|
"6896BD60EEAE296DB48A229FF71DFE071BDE413E6D43F917DC8DCF8C78DE33418906D11AC976ABCCB20B091292BFF4EA897EFCB639EA871CFA95F6DE339E4B0A",
|
||||||
@ -76,9 +76,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
aux_rand: Some(hex_to_bytes::<32>(
|
aux_rand: Some(hex_to_bytes::<32>(
|
||||||
"C87AA53824B4D7AE2EB035A2B5BBBCCC080E76CDC6D1692C4B0B62D798E6D906",
|
"C87AA53824B4D7AE2EB035A2B5BBBCCC080E76CDC6D1692C4B0B62D798E6D906",
|
||||||
)),
|
)),
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"7E2D58D8B3BCDF1ABADEC7829054F90DDA9805AAB56C77333024B9D0A508B75C",
|
"7E2D58D8B3BCDF1ABADEC7829054F90DDA9805AAB56C77333024B9D0A508B75C",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"5831AAEED7B44BB74E5EAB94BA9D4294C49BCF2A60728D8B4C200F50DD313C1BAB745879A5AD954A72C45A91C3A51D3C7ADEA98D82F8481E0E1E03674A6F3FB7",
|
"5831AAEED7B44BB74E5EAB94BA9D4294C49BCF2A60728D8B4C200F50DD313C1BAB745879A5AD954A72C45A91C3A51D3C7ADEA98D82F8481E0E1E03674A6F3FB7",
|
||||||
@ -100,9 +100,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
aux_rand: Some(hex_to_bytes::<32>(
|
aux_rand: Some(hex_to_bytes::<32>(
|
||||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||||
)),
|
)),
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"7EB0509757E246F19449885651611CB965ECC1A187DD51B64FDA1EDC9637D5EC97582B9CB13DB3933705B32BA982AF5AF25FD78881EBB32771FC5922EFC66EA3",
|
"7EB0509757E246F19449885651611CB965ECC1A187DD51B64FDA1EDC9637D5EC97582B9CB13DB3933705B32BA982AF5AF25FD78881EBB32771FC5922EFC66EA3",
|
||||||
@ -117,9 +117,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
))
|
))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
aux_rand: None,
|
aux_rand: None,
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"4DF3C3F68FCC83B27E9D42C90431A72499F17875C81A599B566C9889B9696703",
|
"4DF3C3F68FCC83B27E9D42C90431A72499F17875C81A599B566C9889B9696703",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"00000000000000000000003B78CE563F89A0ED9414F5AA28AD0D96D6795F9C6376AFB1548AF603B3EB45C9F8207DEE1060CB71C04E80F593060B07D28308D7F4",
|
"00000000000000000000003B78CE563F89A0ED9414F5AA28AD0D96D6795F9C6376AFB1548AF603B3EB45C9F8207DEE1060CB71C04E80F593060B07D28308D7F4",
|
||||||
@ -134,7 +134,7 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
// "EEFDEA4CDB677750A420FEE807EACF21EB9898AE79B9768766E4FAA04A2D4A34",
|
// "EEFDEA4CDB677750A420FEE807EACF21EB9898AE79B9768766E4FAA04A2D4A34",
|
||||||
// )).unwrap(),
|
// )).unwrap(),
|
||||||
// aux_rand: None,
|
// aux_rand: None,
|
||||||
// message:
|
// message: Some(
|
||||||
//
|
//
|
||||||
// hex::decode("243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89").
|
// hex::decode("243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89").
|
||||||
// unwrap(), ),
|
// unwrap(), ),
|
||||||
@ -153,9 +153,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
))
|
))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
aux_rand: None,
|
aux_rand: None,
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"FFF97BD5755EEEA420453A14355235D382F6472F8568A18B2F057A14602975563CC27944640AC607CD107AE10923D9EF7A73C643E166BE5EBEAFA34B1AC553E2",
|
"FFF97BD5755EEEA420453A14355235D382F6472F8568A18B2F057A14602975563CC27944640AC607CD107AE10923D9EF7A73C643E166BE5EBEAFA34B1AC553E2",
|
||||||
@ -170,9 +170,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
))
|
))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
aux_rand: None,
|
aux_rand: None,
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"1FA62E331EDBC21C394792D2AB1100A7B432B013DF3F6FF4F99FCB33E0E1515F28890B3EDB6E7189B630448B515CE4F8622A954CFE545735AAEA5134FCCDB2BD",
|
"1FA62E331EDBC21C394792D2AB1100A7B432B013DF3F6FF4F99FCB33E0E1515F28890B3EDB6E7189B630448B515CE4F8622A954CFE545735AAEA5134FCCDB2BD",
|
||||||
@ -187,9 +187,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
))
|
))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
aux_rand: None,
|
aux_rand: None,
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"6CFF5C3BA86C69EA4B7376F31A9BCB4F74C1976089B2D9963DA2E5543E177769961764B3AA9B2FFCB6EF947B6887A226E8D7C93E00C5ED0C1834FF0D0C2E6DA6",
|
"6CFF5C3BA86C69EA4B7376F31A9BCB4F74C1976089B2D9963DA2E5543E177769961764B3AA9B2FFCB6EF947B6887A226E8D7C93E00C5ED0C1834FF0D0C2E6DA6",
|
||||||
@ -204,9 +204,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
))
|
))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
aux_rand: None,
|
aux_rand: None,
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000123DDA8328AF9C23A94C1FEECFD123BA4FB73476F0D594DCB65C6425BD186051",
|
"0000000000000000000000000000000000000000000000000000000000000000123DDA8328AF9C23A94C1FEECFD123BA4FB73476F0D594DCB65C6425BD186051",
|
||||||
@ -221,9 +221,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
))
|
))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
aux_rand: None,
|
aux_rand: None,
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"00000000000000000000000000000000000000000000000000000000000000017615FBAF5AE28864013C099742DEADB4DBA87F11AC6754F93780D5A1837CF197",
|
"00000000000000000000000000000000000000000000000000000000000000017615FBAF5AE28864013C099742DEADB4DBA87F11AC6754F93780D5A1837CF197",
|
||||||
@ -238,9 +238,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
))
|
))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
aux_rand: None,
|
aux_rand: None,
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"4A298DACAE57395A15D0795DDBFD1DCB564DA82B0F269BC70A74F8220429BA1D69E89B4C5564D00349106B8497785DD7D1D713A8AE82B32FA79D5F7FC407D39B",
|
"4A298DACAE57395A15D0795DDBFD1DCB564DA82B0F269BC70A74F8220429BA1D69E89B4C5564D00349106B8497785DD7D1D713A8AE82B32FA79D5F7FC407D39B",
|
||||||
@ -255,9 +255,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
))
|
))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
aux_rand: None,
|
aux_rand: None,
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F69E89B4C5564D00349106B8497785DD7D1D713A8AE82B32FA79D5F7FC407D39B",
|
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F69E89B4C5564D00349106B8497785DD7D1D713A8AE82B32FA79D5F7FC407D39B",
|
||||||
@ -272,9 +272,9 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
))
|
))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
aux_rand: None,
|
aux_rand: None,
|
||||||
message: hex_to_bytes::<32>(
|
message: Some(hex_to_bytes::<32>(
|
||||||
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89",
|
||||||
),
|
)),
|
||||||
signature: Signature {
|
signature: Signature {
|
||||||
value: hex_to_bytes(
|
value: hex_to_bytes(
|
||||||
"6CFF5C3BA86C69EA4B7376F31A9BCB4F74C1976089B2D9963DA2E5543E177769FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141",
|
"6CFF5C3BA86C69EA4B7376F31A9BCB4F74C1976089B2D9963DA2E5543E177769FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141",
|
||||||
@ -289,7 +289,7 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
// "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC30",
|
// "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC30",
|
||||||
// )).unwrap(),
|
// )).unwrap(),
|
||||||
// aux_rand: None,
|
// aux_rand: None,
|
||||||
// message:
|
// message: Some(
|
||||||
//
|
//
|
||||||
// hex::decode("243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89").
|
// hex::decode("243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89").
|
||||||
// unwrap(), ),
|
// unwrap(), ),
|
||||||
@ -303,13 +303,13 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
// },
|
// },
|
||||||
// Test with invalid message length (0); valid test for BIP-340 post 2022.
|
// Test with invalid message length (0); valid test for BIP-340 post 2022.
|
||||||
// TestVector {
|
// TestVector {
|
||||||
// seckey: PrivateKey::try_new(hex_to_bytes(
|
// seckey: Some(PrivateKey::try_new(hex_to_bytes(
|
||||||
// "0340034003400340034003400340034003400340034003400340034003400340",
|
// "0340034003400340034003400340034003400340034003400340034003400340",
|
||||||
// )).unwrap()),
|
// )).unwrap()),
|
||||||
// pubkey: PublicKey::try_new(hex_to_bytes(
|
// pubkey: PublicKey::try_new(hex_to_bytes(
|
||||||
// "778CAA53B4393AC467774D09497A87224BF9FAB6F6E68B23086497324D6FD117",
|
// "778CAA53B4393AC467774D09497A87224BF9FAB6F6E68B23086497324D6FD117",
|
||||||
// )).unwrap(),
|
// )).unwrap(),
|
||||||
// aux_rand: hex_to_bytes::<32>(
|
// aux_rand: Some(hex_to_bytes::<32>(
|
||||||
// "0000000000000000000000000000000000000000000000000000000000000000",
|
// "0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
// )),
|
// )),
|
||||||
// message: None,
|
// message: None,
|
||||||
@ -322,16 +322,16 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
// },
|
// },
|
||||||
// Test with invalid message length (1); valid test for BIP-340 post 2022.
|
// Test with invalid message length (1); valid test for BIP-340 post 2022.
|
||||||
// TestVector {
|
// TestVector {
|
||||||
// seckey: PrivateKey::try_new(hex_to_bytes(
|
// seckey: Some(PrivateKey::try_new(hex_to_bytes(
|
||||||
// "0340034003400340034003400340034003400340034003400340034003400340",
|
// "0340034003400340034003400340034003400340034003400340034003400340",
|
||||||
// )).unwrap()),
|
// )).unwrap()),
|
||||||
// pubkey: PublicKey::try_new(hex_to_bytes(
|
// pubkey: PublicKey::try_new(hex_to_bytes(
|
||||||
// "778CAA53B4393AC467774D09497A87224BF9FAB6F6E68B23086497324D6FD117",
|
// "778CAA53B4393AC467774D09497A87224BF9FAB6F6E68B23086497324D6FD117",
|
||||||
// )).unwrap(),
|
// )).unwrap(),
|
||||||
// aux_rand: hex_to_bytes::<32>(
|
// aux_rand: Some(hex_to_bytes::<32>(
|
||||||
// "0000000000000000000000000000000000000000000000000000000000000000",
|
// "0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
// )),
|
// )),
|
||||||
// message: hex::decode("11").unwrap()),
|
// message: Some(hex::decode("11").unwrap()),
|
||||||
// signature: Signature {
|
// signature: Signature {
|
||||||
// value: hex_to_bytes(
|
// value: hex_to_bytes(
|
||||||
// "08A20A0AFEF64124649232E0693C583AB1B9934AE63B4C3511F3AE1134C6A303EA3173BFEA6683BD101FA5AA5DBC1996FE7CACFC5A577D33EC14564CEC2BACBF",
|
// "08A20A0AFEF64124649232E0693C583AB1B9934AE63B4C3511F3AE1134C6A303EA3173BFEA6683BD101FA5AA5DBC1996FE7CACFC5A577D33EC14564CEC2BACBF",
|
||||||
@ -341,16 +341,16 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
// },
|
// },
|
||||||
// Test with invalid message length (17); valid test for BIP-340 post 2022.
|
// Test with invalid message length (17); valid test for BIP-340 post 2022.
|
||||||
// TestVector {
|
// TestVector {
|
||||||
// seckey: PrivateKey::try_new(hex_to_bytes(
|
// seckey: Some(PrivateKey::try_new(hex_to_bytes(
|
||||||
// "0340034003400340034003400340034003400340034003400340034003400340",
|
// "0340034003400340034003400340034003400340034003400340034003400340",
|
||||||
// )).unwrap()),
|
// )).unwrap()),
|
||||||
// pubkey: PublicKey::try_new(hex_to_bytes(
|
// pubkey: PublicKey::try_new(hex_to_bytes(
|
||||||
// "778CAA53B4393AC467774D09497A87224BF9FAB6F6E68B23086497324D6FD117",
|
// "778CAA53B4393AC467774D09497A87224BF9FAB6F6E68B23086497324D6FD117",
|
||||||
// )).unwrap(),
|
// )).unwrap(),
|
||||||
// aux_rand: hex_to_bytes::<32>(
|
// aux_rand: Some(hex_to_bytes::<32>(
|
||||||
// "0000000000000000000000000000000000000000000000000000000000000000",
|
// "0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
// )),
|
// )),
|
||||||
// message: hex::decode("0102030405060708090A0B0C0D0E0F1011").unwrap()),
|
// message: Some(hex::decode("0102030405060708090A0B0C0D0E0F1011").unwrap()),
|
||||||
// signature: Signature {
|
// signature: Signature {
|
||||||
// value: hex_to_bytes(
|
// value: hex_to_bytes(
|
||||||
// "5130F39A4059B43BC7CAC09A19ECE52B5D8699D1A71E3C52DA9AFDB6B50AC370C4A482B77BF960F8681540E25B6771ECE1E5A37FD80E5A51897C5566A97EA5A5",
|
// "5130F39A4059B43BC7CAC09A19ECE52B5D8699D1A71E3C52DA9AFDB6B50AC370C4A482B77BF960F8681540E25B6771ECE1E5A37FD80E5A51897C5566A97EA5A5",
|
||||||
@ -360,16 +360,16 @@ pub fn test_vectors() -> Vec<TestVector> {
|
|||||||
// },
|
// },
|
||||||
// Test with invalid message length (100); valid test for BIP-340 post 2022.
|
// Test with invalid message length (100); valid test for BIP-340 post 2022.
|
||||||
// TestVector {
|
// TestVector {
|
||||||
// seckey: PrivateKey::try_new(hex_to_bytes(
|
// seckey: Some(PrivateKey::try_new(hex_to_bytes(
|
||||||
// "0340034003400340034003400340034003400340034003400340034003400340",
|
// "0340034003400340034003400340034003400340034003400340034003400340",
|
||||||
// )).unwrap()),
|
// )).unwrap()),
|
||||||
// pubkey: PublicKey::try_new(hex_to_bytes(
|
// pubkey: PublicKey::try_new(hex_to_bytes(
|
||||||
// "778CAA53B4393AC467774D09497A87224BF9FAB6F6E68B23086497324D6FD117",
|
// "778CAA53B4393AC467774D09497A87224BF9FAB6F6E68B23086497324D6FD117",
|
||||||
// )).unwrap(),
|
// )).unwrap(),
|
||||||
// aux_rand: hex_to_bytes::<32>(
|
// aux_rand: Some(hex_to_bytes::<32>(
|
||||||
// "0000000000000000000000000000000000000000000000000000000000000000",
|
// "0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
// )),
|
// )),
|
||||||
// message:
|
// message: Some(
|
||||||
// hex::decode("99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999").unwrap(),
|
// hex::decode("99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999").unwrap(),
|
||||||
// ),
|
// ),
|
||||||
// signature: Signature {
|
// signature: Signature {
|
||||||
|
|||||||
@ -37,7 +37,6 @@ impl FromStr for Signature {
|
|||||||
|
|
||||||
impl Signature {
|
impl Signature {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
/// This function expects the incoming message to be prehashed to be pre-2022 BIP-340/Keycard compatible.
|
|
||||||
pub fn new(key: &PrivateKey, message: &[u8; 32]) -> Self {
|
pub fn new(key: &PrivateKey, message: &[u8; 32]) -> Self {
|
||||||
let mut aux_random = [0_u8; 32];
|
let mut aux_random = [0_u8; 32];
|
||||||
OsRng.fill_bytes(&mut aux_random);
|
OsRng.fill_bytes(&mut aux_random);
|
||||||
@ -62,7 +61,7 @@ impl Signature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn is_valid_for(&self, bytes: &[u8; 32], public_key: &PublicKey) -> bool {
|
pub fn is_valid_for(&self, bytes: &[u8], public_key: &PublicKey) -> bool {
|
||||||
let Ok(pk) = k256::schnorr::VerifyingKey::from_bytes(public_key.value()) else {
|
let Ok(pk) = k256::schnorr::VerifyingKey::from_bytes(public_key.value()) else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@ -98,8 +97,9 @@ mod tests {
|
|||||||
let Some(aux_random) = test_vector.aux_rand else {
|
let Some(aux_random) = test_vector.aux_rand else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let message = test_vector.message;
|
let Some(message) = test_vector.message else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
if !test_vector.verification_result {
|
if !test_vector.verification_result {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn signature_verification_from_bip340_test_vectors() {
|
fn signature_verification_from_bip340_test_vectors() {
|
||||||
for (i, test_vector) in bip340_test_vectors::test_vectors().into_iter().enumerate() {
|
for (i, test_vector) in bip340_test_vectors::test_vectors().into_iter().enumerate() {
|
||||||
let message = test_vector.message;
|
let message = test_vector.message.unwrap_or([0_u8; 32]);
|
||||||
let expected_result = test_vector.verification_result;
|
let expected_result = test_vector.verification_result;
|
||||||
|
|
||||||
let result = test_vector
|
let result = test_vector
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user