Closed nkbai closed 5 years ago
change prove to this:
// Step 5: nonce let mut k = self.generate_nonce(&secret_key, &h_string)?; let mut k=&k+ &BigNum::from_u32(3).unwrap();
give the following test:
#[test] fn test_prove_and_verify(){ let mut vrf = ECVRF::from_suite(CipherSuite::SECP256K1_SHA256_TAI).unwrap(); // Secret Key (labelled as x) let x = hex::decode("c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721") .unwrap(); let secret_key = BigNum::from_slice(&x).unwrap(); let public_key = vrf.derive_public_key_point(&secret_key).unwrap(); let public_key_bytes = public_key .to_bytes(&vrf.group, PointConversionForm::COMPRESSED, &mut vrf.bn_ctx) .unwrap(); println!("{:x?}", public_key_bytes); // Data: ASCII "sample" let alpha = hex::decode("73616d706c65").unwrap(); let pi = vrf.prove(&x, &alpha).unwrap(); // let expected_pi = hex::decode("031f4dbca087a1972d04a07a779b7df1caa99e0f5db2aa21f3aecc4f9e10e85d0814faa89697b482daa377fb6b4a8b0191a65d34a6d90a8a2461e5db9205d4cf0bb4b2c31b5ef6997a585a9f1a72517b6f").unwrap(); // assert_eq!(pi, expected_pi); let y = hex::decode("032c8c31fc9f990c6b55e3865a184a4ce50e09481f2eaeb3e60ec1cea13a6ae645") .unwrap(); let beta = vrf.verify(&y, &pi, &alpha).unwrap(); let expected_beta = hex::decode("612065e309e937ef46c2ef04d5886b9c6efd2991ac484ec64a9b014366fc5d81") .unwrap(); assert_eq!(beta, expected_beta); }
expected_pi test cannot pass,but vrf.verify can pass.
change prove to this:
give the following test:
expected_pi test cannot pass,but vrf.verify can pass.