Class: Secp256k1::MuSig::KeyAggContext
- Inherits:
-
Object
- Object
- Secp256k1::MuSig::KeyAggContext
- Includes:
- Secp256k1
- Defined in:
- lib/secp256k1/musig/key_agg.rb
Overview
Key aggregation context class.
Constant Summary
Constants included from Secp256k1
CONTEXT_SIGN, CONTEXT_VERIFY, EC_COMPRESSED, EC_UNCOMPRESSED, ELL_SWIFT_KEY_SIZE, FLAGS_BIT_COMPRESSION, FLAGS_BIT_CONTEXT_SIGN, FLAGS_BIT_CONTEXT_VERIFY, FLAGS_TYPE_COMPRESSION, FLAGS_TYPE_CONTEXT, FLAGS_TYPE_MASK, VERSION, X_ONLY_PUBKEY_SIZE
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
Instance Method Summary collapse
-
#aggregate_public_key ⇒ String
Get aggregate public key.
-
#initialize(key_agg_cache) ⇒ KeyAggContext
constructor
Constructor.
-
#pointer ⇒ FFI::MemoryPointer
Get KeyAggCache pointer.
-
#tweak_add(tweak, xonly: false) ⇒ String
Apply ordinary “EC” tweaking to a public key.
Methods included from Secp256k1
#create_keypair, #generate_key_pair, #generate_pubkey, #parse_ec_pubkey?, #sign_ecdsa, #valid_xonly_pubkey?, #verify_ecdsa, #with_context
Methods included from Secp256k1::MuSig
#aggregate_musig_nonce, #aggregate_pubkey, #generate_musig_nonce, #generate_musig_session_id
Methods included from EllSwift
#ellswift_create, #ellswift_decode, #ellswift_ecdh_xonly
Methods included from SchnorrSig
#sign_schnorr, #verify_schnorr
Methods included from Recover
Methods included from C
ellswift_xdh_hash_function_bip324
Constructor Details
#initialize(key_agg_cache) ⇒ KeyAggContext
Constructor.
18 19 20 21 |
# File 'lib/secp256k1/musig/key_agg.rb', line 18 def initialize(key_agg_cache) raise ArgumentError, "key_agg_cache must be Secp256k1::KeyAggCache." unless key_agg_cache.is_a?(Secp256k1::KeyAggCache) @cache = key_agg_cache end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
13 14 15 |
# File 'lib/secp256k1/musig/key_agg.rb', line 13 def cache @cache end |
Instance Method Details
#aggregate_public_key ⇒ String
Get aggregate public key.
25 26 27 28 29 30 31 32 33 |
# File 'lib/secp256k1/musig/key_agg.rb', line 25 def aggregate_public_key with_context do |context| agg_pubkey = FFI::MemoryPointer.new(:uchar, 64) if secp256k1_musig_pubkey_get(context, agg_pubkey, cache.pointer) == 0 raise Error, "secp256k1_musig_pubkey_get arguments invalid." end serialize_pubkey(context, agg_pubkey) end end |
#pointer ⇒ FFI::MemoryPointer
Get KeyAggCache pointer.
61 62 63 |
# File 'lib/secp256k1/musig/key_agg.rb', line 61 def pointer cache.pointer end |
#tweak_add(tweak, xonly: false) ⇒ String
Apply ordinary “EC” tweaking to a public key.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/secp256k1/musig/key_agg.rb', line 41 def tweak_add(tweak, xonly: false) validate_string!("tweak", tweak, 32) with_context do |context| tweak_ptr = FFI::MemoryPointer.new(:uchar, 32).put_bytes(0, hex2bin(tweak)) pubkey_ptr = FFI::MemoryPointer.new(:uchar, 64) if xonly if secp256k1_musig_pubkey_xonly_tweak_add(context, pubkey_ptr, cache.pointer, tweak_ptr) == 0 raise Error, "secp256k1_musig_pubkey_tweak_add arguments invalid." end else if secp256k1_musig_pubkey_ec_tweak_add(context, pubkey_ptr, cache.pointer, tweak_ptr) == 0 raise Error, "secp256k1_musig_pubkey_tweak_add arguments invalid." end end serialize_pubkey(context, pubkey_ptr) end end |