-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚧 prepare beginning of implementation of step1
- Loading branch information
1 parent
daaeec3
commit e69f5ed
Showing
4 changed files
with
27 additions
and
128 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,13 @@ | ||
use bdhke::core::MintTrait; | ||
use bdhke::core::MintTraitImpl; | ||
use bdhke::core::UserTrait; | ||
use bdhke::core::UserTraitImpl; | ||
use starknet::{secp256k1::{Secp256k1Point}, secp256_trait::{Secp256Trait, Secp256PointTrait}}; | ||
use core::starknet::SyscallResultTrait; | ||
|
||
use bdhke::core::step1_alice; | ||
|
||
fn main() { | ||
println!("Running Blind Diffie-Hellmann Key Exchange (BDHKE) scheme"); | ||
|
||
// Create a mint (Bob) | ||
let mint_private_key: u256 = 0xe907831f80848d1069a5371b402410364bdf1c5f8307b0084c55f1ce2dca8215; | ||
let mut mint = MintTraitImpl::new(mint_private_key); | ||
|
||
// Create a user (Alice) | ||
let alice_random_secret: u256 = | ||
0xe907831f80848d1069a5371b402410364bdf1c5f8307b0084c55f1ce2dca8215; | ||
let alice_blinding_factor: u256 = | ||
0xe907831f80848d1069a5371b402410364bdf1c5f8307b0084c55f1ce2dca8215; | ||
|
||
let mut alice = UserTraitImpl::new(alice_random_secret, alice_blinding_factor); | ||
|
||
// Alice blinds her message | ||
let B_ = alice.blind(); | ||
|
||
// Mint signs the blinded message | ||
let C_ = mint.sign(B_); | ||
|
||
// Alice unblinds the signature | ||
let C = alice.unblind(C_, mint.K); | ||
|
||
// Alice creates a token | ||
let (x, C) = alice.create_token(C); | ||
|
||
// Mint verifies the token | ||
let is_valid = mint.verify(x, C); | ||
let mut secret_msg = "test_message"; | ||
let blinding_factor: u256 = 0xe907831f80848d1069a5371b402410364bdf1c5f8307b0084c55f1ce2dca8215; | ||
|
||
if is_valid { | ||
println!("Token is valid"); | ||
} else { | ||
println!("Token is invalid"); | ||
} | ||
let (B_, r) = step1_alice(secret_msg, blinding_factor); | ||
} |
Binary file modified
BIN
+195 Bytes
(100%)
tests/references/bdhke-nutshell/__pycache__/bdhke_nutshell.cpython-312-pytest-8.3.2.pyc
Binary file not shown.
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