-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
260 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
contracts/crypto-verify/schema/raw/response_to_verify_bls12_pairing_equality_g1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "VerifyResponse", | ||
"type": "object", | ||
"required": [ | ||
"verifies" | ||
], | ||
"properties": { | ||
"verifies": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} |
14 changes: 14 additions & 0 deletions
14
contracts/crypto-verify/schema/raw/response_to_verify_bls12_pairing_equality_g2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "VerifyResponse", | ||
"type": "object", | ||
"required": [ | ||
"verifies" | ||
], | ||
"properties": { | ||
"verifies": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
use cosmwasm_std::{Api, HashFunction, StdResult}; | ||
use cosmwasm_std::{ | ||
Api, HashFunction, StdResult, BLS12_381_G1_GENERATOR_COMPRESSED, | ||
BLS12_381_G2_GENERATOR_COMPRESSED, | ||
}; | ||
|
||
pub fn verify( | ||
pub fn verify_g1( | ||
api: &dyn Api, | ||
p: &[u8], | ||
q: &[u8], | ||
r: &[u8], | ||
signature: &[u8], | ||
pubkey: &[u8], | ||
msg: &[u8], | ||
dst: &[u8], | ||
) -> StdResult<bool> { | ||
let s = api.bls12_381_hash_to_g2(HashFunction::Sha256, msg, dst)?; | ||
api.bls12_381_pairing_equality(p, q, r, &s) | ||
api.bls12_381_pairing_equality(&BLS12_381_G1_GENERATOR_COMPRESSED, signature, pubkey, &s) | ||
.map_err(Into::into) | ||
} | ||
|
||
pub fn verify_g2( | ||
api: &dyn Api, | ||
signature: &[u8], | ||
pubkey: &[u8], | ||
msg: &[u8], | ||
dst: &[u8], | ||
) -> StdResult<bool> { | ||
let s = api.bls12_381_hash_to_g1(HashFunction::Sha256, msg, dst)?; | ||
api.bls12_381_pairing_equality(signature, &BLS12_381_G2_GENERATOR_COMPRESSED, &s, pubkey) | ||
.map_err(Into::into) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.