Skip to content

Commit

Permalink
Add bls12_381_pairing_equality docs
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed May 2, 2024
1 parent 8078c5c commit faa570c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/std/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,32 @@ pub trait Api {
unimplemented!()
}

/// Checks the following pairing equality:
///
/// e(p_1, q_1) × e(p_2, q_2) × … × e(p_n, q_n) = e(s, q)
///
/// The argument `ps` contain the points p_1, ..., p_n ∈ G1 as a concatenation of 48 byte elements.
/// The argument `qs` contain the points q_1, ..., q_n ∈ G2 as a concatenation of 96 byte elements.
///

Check warning on line 206 in packages/std/src/traits.rs

View check run for this annotation

Codecov / codecov/patch

packages/std/src/traits.rs#L204-L206

Added lines #L204 - L206 were not covered by tests
/// ## Examples
///
/// A simple signature check with one pairing on the left hand side (e(p, q) = e(s, q)):
///
/// ```
/// # use cosmwasm_std::{Api, HashFunction, StdResult};
/// pub fn verify(
/// api: &dyn Api,

Check warning on line 214 in packages/std/src/traits.rs

View check run for this annotation

Codecov / codecov/patch

packages/std/src/traits.rs#L212-L214

Added lines #L212 - L214 were not covered by tests
/// g1_generator: &[u8],
/// signature: &[u8],
/// pubkey: &[u8],
/// msg: &[u8],
/// dst: &[u8],

Check warning on line 219 in packages/std/src/traits.rs

View check run for this annotation

Codecov / codecov/patch

packages/std/src/traits.rs#L217-L219

Added lines #L217 - L219 were not covered by tests
/// ) -> StdResult<bool> {
/// let msg_hashed = api.bls12_381_hash_to_g2(HashFunction::Sha256, msg, dst)?;
/// api.bls12_381_pairing_equality(g1_generator, signature, pubkey, &msg_hashed)
/// .map_err(Into::into)
/// }
/// ```

Check warning on line 225 in packages/std/src/traits.rs

View check run for this annotation

Codecov / codecov/patch

packages/std/src/traits.rs#L222-L225

Added lines #L222 - L225 were not covered by tests
#[allow(unused_variables)]
fn bls12_381_pairing_equality(

Check warning on line 227 in packages/std/src/traits.rs

View check run for this annotation

Codecov / codecov/patch

packages/std/src/traits.rs#L227

Added line #L227 was not covered by tests
&self,
Expand Down

0 comments on commit faa570c

Please sign in to comment.