Git Product home page Git Product logo

vrf-rs's People

Contributors

aesedepece avatar girazoki avatar mariocao avatar tmpolaczyk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vrf-rs's Issues

Instructions

Hi!

Could you put installation instructions on the README?

Or at least how to run the examples would be useful.

Different results

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,

Is there a serious theoretical error in this article?

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.

Compile error openssl-sys v0.9.72

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

Support BLS_12_381 Curve?

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

Is there a serious theoretical error in this article?

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.

Expose openssl's vendored feature

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"] }

On RaspberryPi ARM32v7 thread 'main' panicked at 'attempt to shift right with overflow', /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/hmac-sha256-0.1.1/src/lib.rs:261:33

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.