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
- Alice generates a secret
tand publishes the adaptor pointT = t*G - Bob creates a pre-signature that’s “locked” to
T - Alice can verify the pre-signature is correct
- Alice completes the signature using her secret
t - When Alice publishes the complete signature, Bob can extract
t - Bob can now use
tto 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§
- Adaptor
Point - The public adaptor point (commitment to the secret)
- Adaptor
Public Key - Public key for adaptor signatures
- Adaptor
Secret - The secret value used to lock/unlock signatures
- Adaptor
Secret Key - Secret key for adaptor signatures
- Adaptor
Signature - Complete signature (standard Schnorr signature)
- Adaptor
Signer - Signer for adaptor signatures
- PreSignature
- Pre-signature (locked to an adaptor point)
Enums§
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