Skip to content

Commit

Permalink
chore: merge crypto-module into keyset
Browse files Browse the repository at this point in the history
  • Loading branch information
ngutech21 committed Oct 26, 2023
1 parent a9f3b9f commit 4535599
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 207 deletions.
167 changes: 0 additions & 167 deletions moksha-core/src/crypto.rs

This file was deleted.

59 changes: 29 additions & 30 deletions moksha-core/src/dhke.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
//! Implementation of `<https://gist.github.com/RubenSomsen/be7a4760dd4596d06963d67baf140406>`
//!
//! Bob (Mint):
//! A = a*G
//! return A
//!
//! Alice (Client):
//! Y = hash_to_curve(secret_message)
//! r = random blinding factor
//! B'= Y + r*G
//! return B'
//!
//! Bob:
//! C' = a*B'
//! (= a*Y + a*r*G)
//! return C'
//!
//! Alice:
//! C = C' - r*A
//! (= C' - a*r*G)
//! (= a*Y)
//! return C, secret_message
//!
//! Bob:
//! Y = hash_to_curve(secret_message)
//! C == a*Y
//! If true, C must have originated from Bob
//!
use crate::error::MokshaCoreError;
use bitcoin_hashes::{sha256, Hash};
use secp256k1::{All, PublicKey, Scalar, Secp256k1, SecretKey};

use crate::error::MokshaCoreError;

/// Implementation of `<https://gist.github.com/RubenSomsen/be7a4760dd4596d06963d67baf140406>`
///
/// Bob (Mint):
/// A = a*G
/// return A
///
/// Alice (Client):
/// Y = hash_to_curve(secret_message)
/// r = random blinding factor
/// B'= Y + r*G
/// return B'
///
/// Bob:
/// C' = a*B'
/// (= a*Y + a*r*G)
/// return C'
///
/// Alice:
/// C = C' - r*A
/// (= C' - a*r*G)
/// (= a*Y)
/// return C, secret_message
///
/// Bob:
/// Y = hash_to_curve(secret_message)
/// C == a*Y
/// If true, C must have originated from Bob
#[derive(Clone)]
pub struct Dhke {
secp: Secp256k1<All>,
Expand Down
Loading

0 comments on commit 4535599

Please sign in to comment.