hash_to_p3 working

This commit is contained in:
rishflab 2021-04-20 16:34:44 +10:00
parent ade9e3eabf
commit b2ff7eff73
2 changed files with 15 additions and 17 deletions

View File

@ -10,11 +10,11 @@ void hash_to_scalar(const uint8_t *in, uint8_t *md) {
// Hash a key to p3 representation // Hash a key to p3 representation
void hash_to_p3(const uint8_t *in, ge_p3 *hash8_p3) { void hash_to_p3(const uint8_t *in, ge_p3 *hash8_p3) {
uint8_t md[32]; uint8_t md[32];
keccak(in, 32, md, 32);
ge_p2 hash_p2; ge_p2 hash_p2;
ge_fromfe_frombytes_vartime(&hash_p2, md);
ge_p1p1 hash8_p1p1; ge_p1p1 hash8_p1p1;
keccak(in, 32, md, 32);
ge_fromfe_frombytes_vartime(&hash_p2, md);
ge_mul8(&hash8_p1p1, &hash_p2); ge_mul8(&hash8_p1p1, &hash_p2);
ge_p1p1_to_p3(hash8_p3, &hash8_p1p1); ge_p1p1_to_p3(hash8_p3, &hash8_p1p1);
} }

View File

@ -736,7 +736,7 @@ mod tests2 {
// "83efb774657700e37291f4b8dd10c839d1c739fd135c07a2fd7382334dafdd6a"; // "83efb774657700e37291f4b8dd10c839d1c739fd135c07a2fd7382334dafdd6a";
// let decoded_input = hex::decode(input).unwrap(); // let decoded_input = hex::decode(input).unwrap();
let input = "e4bfca0ffc308fc7c344654307a32ab3008bcf5070523133093d4387341ce4d9"; let input = "a7fbdeeccb597c2d5fdaf2ea2e10cbfcd26b5740903e7f6d46bcbf9a90384fc6";
let decoded_input = hex::decode(input).unwrap(); let decoded_input = hex::decode(input).unwrap();
let mut p3 = ge_p3 { let mut p3 = ge_p3 {
@ -750,21 +750,19 @@ mod tests2 {
unsafe { unsafe {
hash_to_p3(decoded_input.as_ptr() as *const u8, &mut p3); hash_to_p3(decoded_input.as_ptr() as *const u8, &mut p3);
dbg!(&p3); dbg!(&p3);
// dbg!(&compressed); ge_p3_tobytes(&mut compressed as *mut u8, &p3);
// ge_p3_tobytes(&mut compressed as *mut u8, &p3);
}; };
// let actual = CompressedEdwardsY::from_slice(&compressed[..]); dbg!(&compressed);
//
// let decoded = hex::decode( let actual = CompressedEdwardsY::from_slice(&compressed[..]);
// "
// 2789ecbaf36e4fcb41c6157228001538b40ca379464b718d830c58caae7ea4ca", let decoded =
// ) hex::decode("f055ba2d0d9828ce2e203d9896bfda494d7830e7e3a27fa27d5eaa825a79a19c")
// .unwrap(); .unwrap();
// let expected = CompressedEdwardsY::from_slice(decoded.as_slice()); let expected = CompressedEdwardsY::from_slice(decoded.as_slice());
//
// assert_eq!(expected, actual); assert_eq!(expected, actual);
} }
} }