Class: Sigma::Wallet

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/sigma/wallet.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



20
21
22
# File 'lib/sigma/wallet.rb', line 20

def pointer
  @pointer
end

Class Method Details

.create_from_mnemonic(mnemonic_phrase, mnemonic_pass) ⇒ Wallet

Create Wallet instance loading secret key from mnemonic. Throws error if a DlogSecretKey cannot be parsed from the provided phrase

Parameters:

  • mnemonic_phrase (String)
  • mnemonic_pass (String)

Returns:



27
28
29
30
31
32
# File 'lib/sigma/wallet.rb', line 27

def self.create_from_mnemonic(mnemonic_phrase, mnemonic_pass)
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_wallet_from_mnemonic(mnemonic_phrase, mnemonic_pass, pointer)
  Util.check_error!(error)
  init(pointer)
end

.create_from_secrets(secrets) ⇒ Wallet

Create Wallet from secrets

Parameters:

Returns:



37
38
39
40
41
# File 'lib/sigma/wallet.rb', line 37

def self.create_from_secrets(secrets)
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_wallet_from_secrets(secrets.pointer, pointer)
  init(pointer)
end

Instance Method Details

#add_secret(secret) ⇒ Object

Add a secret to the wallet’s prover

Parameters:



45
46
47
48
# File 'lib/sigma/wallet.rb', line 45

def add_secret(secret)
  error = ergo_lib_wallet_add_secret(self.pointer, secret.pointer)
  Util.check_error!(error)
end

#generate_commitments(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:) ⇒ TransactionHintsBag

Generate Commitments for unsigned tx

Parameters:

Returns:



104
105
106
107
108
109
# File 'lib/sigma/wallet.rb', line 104

def generate_commitments(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:)
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_wallet_generate_commitments(self.pointer, state_context.pointer, unsigned_tx.pointer, boxes_to_spend.pointer, data_boxes.pointer, pointer)
  Util.check_error!(error)
  Sigma::TransactionHintsBag.with_raw_pointer(pointer)
end

#generate_commitments_for_reduced_transaction(reduced_tx) ⇒ TransactionHintsBag

Generate Commitments for reduced transaction

Parameters:

Returns:



114
115
116
117
118
119
# File 'lib/sigma/wallet.rb', line 114

def generate_commitments_for_reduced_transaction(reduced_tx)
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_wallet_generate_commitments_for_reduced_transaction(self.pointer, reduced_tx.pointer, pointer)
  Util.check_error!(error)
  Sigma::TransactionHintsBag.with_raw_pointer(pointer)
end

#sign_reduced_transaction(reduced_tx) ⇒ Transaction

Signs a reduced transaction (generating proofs for inputs)

Parameters:

Returns:



80
81
82
83
84
85
# File 'lib/sigma/wallet.rb', line 80

def sign_reduced_transaction(reduced_tx)
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_wallet_sign_reduced_transaction(self.pointer, reduced_tx.pointer, pointer)
  Util.check_error!(error)
  Sigma::Transaction.with_raw_pointer(pointer)
end

#sign_reduced_transaction_multi(reduced_tx:, tx_hints:) ⇒ Transaction

Signs a multi signature reduced transaction

Parameters:

Returns:



91
92
93
94
95
96
# File 'lib/sigma/wallet.rb', line 91

def sign_reduced_transaction_multi(reduced_tx:, tx_hints:)
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_wallet_sign_reduced_transaction_multi(self.pointer, reduced_tx.pointer, tx_hints.pointer, pointer)
  Util.check_error!(error)
  Sigma::Transaction.with_raw_pointer(pointer)
end

#sign_transaction(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:) ⇒ Transaction

Sign a transaction

Parameters:

Returns:



56
57
58
59
60
61
# File 'lib/sigma/wallet.rb', line 56

def sign_transaction(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:)
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_wallet_sign_transaction(self.pointer, state_context.pointer, unsigned_tx.pointer, boxes_to_spend.pointer, data_boxes.pointer, pointer)
  Util.check_error!(error)
  Sigma::Transaction.with_raw_pointer(pointer)
end

#sign_transaction_multi(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:, tx_hints:) ⇒ Transaction

Sign a multi-signature transaction

Parameters:

Returns:



70
71
72
73
74
75
# File 'lib/sigma/wallet.rb', line 70

def sign_transaction_multi(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:, tx_hints:)
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_wallet_sign_transaction_multi(self.pointer, state_context.pointer, unsigned_tx.pointer, boxes_to_spend.pointer, data_boxes.pointer, tx_hints.pointer, pointer)
  Util.check_error!(error)
  Sigma::Transaction.with_raw_pointer(pointer)
end