Giter Club home page Giter Club logo

agora-blsful's Introduction

Hyperledger Labs

Hyperledger Labs provides a space (i.e., GitHub repos) where work can easily be started without the creation of a project. Please refer to the Hyperledger Labs wiki page for additional information.

Process to propose a new lab

  1. Fork the hyperledger-labs.github.io repository.

  2. Fill out the Proposal Template and save it into the labs subdirectory under the name of your lab, such as labs/mynewlab.md. It is expected that your lab repository will have the same name so keep that in mind.

  3. In the Proposal Template, there is an entry for sponsor(s). Although not required, proposers are encouraged to seek a sponsor who can help them create ties with the rest of the Hyperledger community and ensure that the proposal is cogent and novel (in conception, proposed execution, or interested community).

    To find sponsors:

    1. use your connections to existing projects and ask maintainers,
    2. find working groups or projects with affinities to the proposed lab and pitch the project (good to have the template already filled out) in associated channels and/or mailing lists. The WG chairs emails, the maintainers contacts etc can be found on the wiki or github. Make personal appeals if you can. Every repository contains a MAINTAINERS file that lists the current maintainers with their contact information and you can reach them all by posting to the Maintainers list.
  4. Commit your changes with proper sign-off. This means that your commit log message must contain a line that looks like the following one, with your actual name and email address:

     Signed-off-by: John Doe <[email protected]>
    

    Adding the -s flag to your git commit command will add that line automatically. You can also add it manually as part of your commit log message or add it afterwards with git commit --amend -s.

  5. Submit a Pull Request.

The labs stewards will then review your proposal. Like sponsors, stewards do not have a responsibility beyond this; ongoing work like contributing code or reviews is not tied to their role as stewards. In reviewing the proposal, the stewards make sure that the proposal is cogent and novel (in conception, proposed execution, or interested community).

IMPORTANT: It is up to the proposer to ensure that any comments or requested changes by the lab stewards are addressed. Failure to do so may delay the approval of your proposal.

Bringing in an existing repository

By default the Lab stewards will create a new repository for you to start from but if you have an existing github repo you would like to bring to your proposed lab you have the option to request for that repo to be reused instead. This is however only possible if every commit in your existing repo is signed-off so there is no DCO related issues. If that is not the case, you have two options:

  1. bring your code by squashing all of your commits into a single first commit made against your new lab repo with your sign-off.

  2. amend the commit history to include DCO sign-off for each of the commits. The Hyperledger Indy community has documented steps to fix DCO on previous commits. Also, the Fix DCO Guide from src-d contains some different steps you can take.

IMPORTANT: Regardless of which option you use, please be sure that the past committers to your project agree to the DCO.

Archiving

Stewards are responsible for curating the set of labs, archiving (see below) those that become dormant or unresponsive for an extended period (3+ months), or are explicitly deemed by the committers to be deprecated/obsoleted.

Deprecated, obsoleted, or dormant labs (as defined above) will be marked as "archived" in GitHub; that signifies that the lab is no longer maintained. Archived labs are read-only, and they can be moved back out of the archives, if there is interest in reviving them.

License requirement

All Hyperledger software must be made available under an Apache 2.0 license. This applies to Labs. Please, make sure to license all incoming code and new code accordingly, and ensure that all commits are made with proper sign-off so that no DCO related issue is introduced.

Code of Conduct

All Hyperledger community members must adhere to the Code of Conduct.

agora-blsful's People

Contributors

cairomassimo avatar dhuseby avatar mikelodder7 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

agora-blsful's Issues

Cleanest way to validate a signature

I'm trying to performance test this library against other libraries in languages I'm more familiar with so I apologize for the newbie question. I wrote this function which works:

// all inputs are presented as hex encoded strings
fn validate_signature(pubkey: &str, message: &str, signature: &str) -> bool {
    let pubkey_bytes = hex::decode(pubkey).expect("pub key must be correct");
    let pubkey: PublicKey<Bls12381G2Impl> = serde_bare::from_slice::<PublicKey<Bls12381G2Impl>>(pubkey_bytes.as_slice()).expect("must be able deserialize pubkey");
    let msg = hex::decode(message).expect("failed to decode hex value");

    let mut sig_vector = vec![0; 97]; // a signature is 96 bytes, plus we're going to add a leading 1
    let last_bytes = &mut sig_vector[1..];    

    hex::decode_to_slice(signature, last_bytes).expect("must be valid sig");
    
    let sig = serde_bare::from_slice::<blsful::Signature<Bls12381G2Impl>>(sig_vector.as_slice()).expect("must be able to deserialize sig");
    let valid = sig.verify(&pubkey, msg);

    valid.is_ok()
}

I'm just wondering if there's any improvements you can see. I couldn't figure out how to deserialize a "BasicSignature" without the prepending of 0 hack I used there.

Thanks very much!

SecretKeyShare/PublicKeyShare incompatiiblity with gennaro_bls secret key share and public key share

Notice the test here: https://github.com/webb-tools/gadget/pull/60/files#diff-859b3cbc12cbcc4dd8fd5b3fb2c3f70b07d5d7e136b769be36443976607dcfcaR330-R345

When mapping from a gennaro BLS secret share to a blsful secret share, there is a failure in deserialization because there is no standardized way of doing this between the two crates. Blsful uses serde, whereas gennaro has no export option using the same serde methods for serialization. I imagine the same is true for the public key shares too.

If there can be a from_raw_be and from_from_compressed for secret shares and public shares, respectively, this should solve our issue.

Unable to target wasm32

When attempting to target wasm32 as a compilation target the following errors are generated

warning: [email protected]: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: [email protected]: 1 error generated.

error: failed to run custom build command for `blst v0.3.11`

Caused by:
  process didn't exit successfully: `/Users/joshlong/Documents/repos/js-sdk/packages/wasm/rust/target/debug/build/blst-72543071d0267c79/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=BLST_TEST_NO_STD
  Using blst source directory /Users/joshlong/.cargo/registry/src/index.crates.io-6f17d22bba15001f/blst-0.3.11/blst
  cargo:rerun-if-changed=/Users/joshlong/.cargo/registry/src/index.crates.io-6f17d22bba15001f/blst-0.3.11/blst/src
  TARGET = Some("wasm32-unknown-unknown")
  OPT_LEVEL = Some("0")
  HOST = Some("aarch64-apple-darwin")
  cargo:rerun-if-env-changed=CC_wasm32-unknown-unknown
  CC_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CC_wasm32_unknown_unknown
  CC_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
  CFLAGS_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
  CFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CC_wasm32-unknown-unknown
  CC_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CC_wasm32_unknown_unknown
  CC_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
  CFLAGS_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
  CFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CC_wasm32-unknown-unknown
  CC_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CC_wasm32_unknown_unknown
  CC_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
  CFLAGS_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
  CFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CC_wasm32-unknown-unknown
  CC_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CC_wasm32_unknown_unknown
  CC_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
  CFLAGS_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
  CFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CC_wasm32-unknown-unknown
  CC_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CC_wasm32_unknown_unknown
  CC_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
  CFLAGS_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
  CFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.

  --- stderr


  error occurred: Command "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-ffreestanding" "-D__BLST_NO_ASM__" "-DSCRATCH_LIMIT=(45 * 1024)" "-o" "/Users/joshlong/Documents/repos/js-sdk/packages/wasm/rust/target/wasm32-unknown-unknown/debug/build/blst-ca8b3dc9d943cc68/out/eaa7fbf6c0a92a5c-server.o" "-c" "/Users/joshlong/.cargo/registry/src/index.crates.io-6f17d22bba15001f/blst-0.3.11/blst/src/server.c" with args clang did not execute successfully (status code exit status: 1).


warning: build failed, waiting for other jobs to finish...
For more information about this error, try `rustc --explain E0308`.
error: could not compile `bls12_381_plus` (lib) due to 1 previous error
Error: Compiling your crate to WebAssembly failed
Caused by: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
  full command: cd "./rust" && "cargo" "build" "--lib" "--target" "wasm32-unknown-unknown"
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Type Mismatch error from `bls12_381_plus-0.8.1`

When attempting to. compile the following error is emitted:

   Compiling blst v0.3.11
   Compiling bls12_381_plus v0.8.13
error[E0308]: mismatched types
    --> /Users/joshlong/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bls12_381_plus-0.8.13/src/scalar.rs:1394:9
     |
1386 |     fn reduce(n: U512) -> Self {
     |                           ---- expected `Scalar` because of return type
...
1394 |         Self::from_raw(out)
     |         ^^^^^^^^^^^^^^^^^^^ expected `Scalar`, found `CtOption<Scalar>`
     |
     = note: expected struct `Scalar`
                found struct `CtOption<Scalar>`

The following warnings were emitted during compilation:

Converting bytes into a private key

Firstly I apologize as this isn't exactly an issue, but a request for help.

Secondly thanks for your amazing work with your library, it is in some cases is 39x faster than a pure javascript solution that I've been trying to port.

The only operation I need which I can't figure out to do is how to convert a 40 byte hash as a PrivateKey. In the javascript version it starts with a hash, e.g.

[202, 109, 60, 56, 243, 94, 234, 17, 222, 103, 73, 119, 83, 36, 172, 68, 181, 27, 66, 32, 61, 12, 118, 192, 255, 103, 26, 98, 247, 20, 156, 130, 140, 217, 185, 187, 43, 215, 139, 219]

then reads it as a bigint: 1831827922067354517797306176892828000911014916050637590219351031477825861890959663243477624057290

Then it does (num % (ORDER - 1)) + 1
where ORDER is defined as: 52435875175126190479447740508185965837690552500527637822603658699938581184513 aka 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001 (and the same as MODULUS in blsful)

Which gives a final result of 9867581098058959301707420087865031789140716346047138769054786295276093541340

thus the private key should be: [ 220, 139, 215, 43, 196, 7, 64, 103, 91, 124, 132, 104, 105, 60, 61, 183, 200, 59, 106, 227, 61, 213, 187, 251, 112, 208, 101, 3, 93, 218, 208, 21 ]

This operation needs to be done extensively, so I want to make sure I'm doing it in the best way possible rather than something naive like converting it to bignum's and doing maths.

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.