Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vrf Audit #156

Merged
merged 10 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ bincode = "1.0"
criterion = "0.4.0"
hashbrown = "0.13.1"
quickcheck = "1.0.0"
rand_core = { version = "^0.6.0", features = ["getrandom"] }

[[bench]]
name = "merkle_path"
Expand Down
16 changes: 14 additions & 2 deletions primitives/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,17 @@
/// ciphersuite identifier for schnorr signature
pub const CS_ID_SCHNORR: &str = "SCHNORR_WITH_RESCUE_HASH_v01";

/// ciphersuite identifier for BLS signature
pub const CS_ID_BLS_SIG_NAIVE: &str = "BLS_SIG_WITH_NAIVE_HtG_v01";
/// ciphersuite identifier for BLS signature, see:
/// https://www.ietf.org/archive/id/draft-irtf-cfrg-bls-signature-05.html#name-ciphersuite-format
pub const CS_ID_BLS_MIN_SIG: &str = "BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_";
tessico marked this conversation as resolved.
Show resolved Hide resolved
tessico marked this conversation as resolved.
Show resolved Hide resolved

/// Size in bytes of a secret key in our BLS signature scheme.
pub const BLS_SIG_SK_SIZE: usize = 32;
/// Size in bytes of a signature in our BLS signature scheme.
pub const BLS_SIG_SIGNATURE_SIZE: usize = 96;
/// Size in bytes of a compressed signature in our BLS signature scheme.
pub const BLS_SIG_COMPRESSED_SIGNATURE_SIZE: usize = 48;
/// Size in bytes of a verification key in our BLS signature scheme.
pub const BLS_SIG_PK_SIZE: usize = 192;
/// Size in bytes of a compressed verification key in our BLS signature scheme.
pub const BLS_SIG_COMPRESSED_PK_SIZE: usize = 96;
21 changes: 18 additions & 3 deletions primitives/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

use crate::rescue::errors::RescueError;
use ark_serialize::SerializationError;
use ark_std::string::String;
use ark_std::{
format,
string::{String, ToString},
};
use blst::BLST_ERROR;
use displaydoc::Display;

/// A `enum` specifying the possible failure modes of the primitives.
Expand Down Expand Up @@ -43,5 +47,16 @@ impl From<SerializationError> for PrimitivesError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for PrimitivesError {}
impl From<BLST_ERROR> for PrimitivesError {
fn from(e: BLST_ERROR) -> Self {
match e {
BLST_ERROR::BLST_SUCCESS => {
Self::InternalError("Expecting an error, but got a sucess.".to_string())
},
BLST_ERROR::BLST_VERIFY_FAIL => Self::VerificationError(format!("{:?}", e)),
_ => Self::ParameterError(format!("{:?}", e)),
}
}
}

impl ark_std::error::Error for PrimitivesError {}
Loading