Module adaptor

Module adaptor 

Source
Expand description

Adaptor Signatures for Atomic Swaps.

Adaptor signatures enable atomic swaps and scriptless scripts by “locking” a signature to a secret value. Once the signature is published, the secret is automatically revealed, enabling trustless cross-chain atomic swaps.

§Protocol Overview

  1. Alice generates a secret t and publishes the adaptor point T = t*G
  2. Bob creates a pre-signature that’s “locked” to T
  3. Alice can verify the pre-signature is correct
  4. Alice completes the signature using her secret t
  5. When Alice publishes the complete signature, Bob can extract t
  6. Bob can now use t to claim funds on another chain

§Example

use chie_crypto::adaptor::*;

// Alice generates a secret for the atomic swap
let secret = AdaptorSecret::random();
let adaptor_point = secret.to_point();

// Bob creates a locked signature
let signer = AdaptorSigner::new();
let message = b"Payment to Alice";

let pre_sig = signer.create_pre_signature_with_secret(message, &secret).unwrap();

// Alice verifies the pre-signature is valid
assert!(verify_pre_signature(&signer.public_key(), message, &pre_sig, &adaptor_point));

// Alice completes the signature using her secret
let complete_sig = complete_signature(&pre_sig, &secret).unwrap();

// Alice publishes the complete signature
assert!(verify_adaptor_signature(&signer.public_key(), message, &complete_sig));

// Bob extracts Alice's secret from the signatures
let extracted = extract_secret(&pre_sig, &complete_sig, &adaptor_point).unwrap();
assert_eq!(secret.to_bytes(), extracted.to_bytes());

Structs§

AdaptorPoint
The public adaptor point (commitment to the secret)
AdaptorPublicKey
Public key for adaptor signatures
AdaptorSecret
The secret value used to lock/unlock signatures
AdaptorSecretKey
Secret key for adaptor signatures
AdaptorSignature
Complete signature (standard Schnorr signature)
AdaptorSigner
Signer for adaptor signatures
PreSignature
Pre-signature (locked to an adaptor point)

Enums§

AdaptorError

Functions§

complete_signature
Complete a pre-signature using the adaptor secret
extract_secret
Extract the secret from pre-signature and complete signature
verify_adaptor_signature
Verify a complete adaptor signature
verify_pre_signature
Verify a pre-signature is valid

Type Aliases§

AdaptorResult