Skip to content

Commit

Permalink
Merge branch 'main' into ark-sponge-traits
Browse files Browse the repository at this point in the history
  • Loading branch information
tessico authored Dec 8, 2022
2 parents 2c817a4 + 1cbf864 commit a25088e
Show file tree
Hide file tree
Showing 6 changed files with 295 additions and 97 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ and follow [semantic versioning](https://semver.org/) for our releases.
- Remove all `.*sponge.*` methods from `Permutation`.
- Introduce `RescueCRHF` which takes over `sponge_with_padding` and `sponge_no_padding` from `Permutation`.
- Introduce `RescuePRF` which takes over `full_state_keyed_sponge_with_padding` and `full_state_keyed_sponge_no_padding` from `Permutation`.
- [#148](https://github.com/EspressoSystems/jellyfish/pull/148), [#156](https://github.com/EspressoSystems/jellyfish/pull/156) (`jf-primitives`) Refactored BLS Signature implementation
- #148 Added trait bounds on associated types of `trait SignatureScheme`
- #156 Improved BLS correctness and API compliance with IRTF standard with better doc

### Fixed

Expand Down
1 change: 1 addition & 0 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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
13 changes: 9 additions & 4 deletions primitives/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +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_";

/// Size in bytes of a secret key in our BLS signature scheme.
pub const BLS_SIG_KEY_SIZE: usize = 32;
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_VERKEY_SIZE: usize = 192;
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

0 comments on commit a25088e

Please sign in to comment.