witnet / vrf-rs Goto Github PK
View Code? Open in Web Editor NEWVerifiable Random Function (VRF) library written in Rust
License: MIT License
Verifiable Random Function (VRF) library written in Rust
License: MIT License
Here are the error details
dyld[1883]: symbol not found in flat namespace '_BN_CTX_free' error: test failed, to rerun pass --lib
Do you have plan replace failure from dependencies
I am using https://crates.io/crates/secp256k1, to create secp2561k keypairs and then this lib to make VRF's around them. However, the public key derived using this lib is different from the one in secp2561k. Am I doing something wrong on my end?
Update the VRF library in order to be compliant with the new draft of the VRF draft.
h_string
)Can you include a client version for command line? Just like vdf-cli but for vrf:
https://github.com/poanetwork/vdf/tree/master/vdf-cli
Thanks!
Hi!
Could you put installation instructions on the README?
Or at least how to run the examples would be useful.
Hi Mario and others,
Congrats for the great ECVRF implementation!
I made an implementation in C using the secp256k1 curve as you can check here
As there is no specification of suite string for this curve on IETF draft yet, I used the same number (0xFE
) that you used here for compatibility.
Unfortunately the proofs are not completely the same: the first 2 parts, Gamma
and c
, match on our implementations. But the last part, s
, differs.
Interestingly, the proof is verified correctly by the verify function. And the proofs you are using here do not pass the verification there.
I was wondering if this could be due to some curve parameter, but as the other parts are OK, it may not be. It could be just the last calculation of s
. But then the proof would not pass the verification.
If you have any idea that could help, it would be very appreciated.
Cheers,
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.
I thinks this is not a valid VRF generator.
I can't compile the project due to an error: failed to run custom build command for openssl-sys v0.9.72
How to fix it? I tried adding crates:
openssl = { version = "0.10.38", features = ["vendored"] }
openssl-sys="0.9.72"
But it didn't work.
My env:
OS: Windows7
CPU: Intel Core i5
Rust(stable): rustc 1.58.1
Can it support bls 12_381 curve.?
And i am getting one issue while compiling using this crate?
dyld[1883]: symbol not found in flat namespace '_BN_CTX_free'
error: test failed, to rerun pass --lib
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.
First off i love the library. However, to cross-compile I must employ openssl's vendored feature. Unlike most crates that depend on it you have not exposed this (https://docs.rs/openssl/latest/openssl/). Would you be able to expose this transitive dependency feature under a name like "openssl-vendored" so I could so something like:
vrf = { version = "0.1.0", features = ["openssl-vendored"] }
I checked the source code.
/// Compute SHA256(absorbed content)
pub fn finalize(mut self) -> [u8; 32] {
let mut padded = [0u8; 128];
padded[..self.r].copy_from_slice(&self.w[..self.r]);
padded[self.r] = 0x80;
let r = if self.r < 56 { 64 } else { 128 };
let bits = self.len * 8;
for i in 0..8 {
padded[r - 8 + i] = (bits >> (56 - i * 8)) as u8;
}
self.state.blocks(&padded[..r]);
let mut out = [0u8; 32];
self.state.store(&mut out);
out
}
The bit shift cause problem on ARM CPU, but won't cause any problem on X86 ( I cannot reproduce this bug on my Mac).
I found some others have fix like this:
sile/libflate@337eb3c
From
let bits = (self.last_read >> self.offset) as u16;
to
debug_assert!(self.offset < 32 || bitwidth == 0);
let bits = self.last_read.wrapping_shr(self.offset as u32) as u16;
I have not tried this in VRF code, but I would like to ask first
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.