Module: Kernel

Defined in:
lib/runar.rb

Overview

Define top-level helper functions on Kernel for use outside contract instances (e.g., in test setup code: ‘hash160(mock_pub_key)`). This is intentional —the gem is purpose-built for Runar contracts, not a general-purpose library, and matches the Python SDK’s approach of exposing builtins at module scope.

Instance Method Summary collapse

Instance Method Details

#bin2num(data) ⇒ Object



170
171
172
# File 'lib/runar.rb', line 170

def bin2num(data)
  Runar.bin2num(data)
end

#blake3_compress(chaining_value, block) ⇒ Object



157
158
159
# File 'lib/runar.rb', line 157

def blake3_compress(chaining_value, block)
  Runar.blake3_compress(chaining_value, block)
end

#blake3_hash(message) ⇒ Object



161
162
163
# File 'lib/runar.rb', line 161

def blake3_hash(message)
  Runar.blake3_hash(message)
end

#bool(n) ⇒ Object



243
244
245
# File 'lib/runar.rb', line 243

def bool(n)
  Runar.bool(n)
end

#cat(a, b) ⇒ Object



174
175
176
# File 'lib/runar.rb', line 174

def cat(a, b)
  Runar.cat(a, b)
end

#check_multi_sig(sigs, pks) ⇒ Object



109
110
111
# File 'lib/runar.rb', line 109

def check_multi_sig(sigs, pks)
  Runar.check_multi_sig(sigs, pks)
end

#check_preimage(preimage) ⇒ Object



113
114
115
# File 'lib/runar.rb', line 113

def check_preimage(preimage)
  Runar.check_preimage(preimage)
end

#check_sig(sig, pk) ⇒ Object

Crypto mocks



105
106
107
# File 'lib/runar.rb', line 105

def check_sig(sig, pk)
  Runar.check_sig(sig, pk)
end

#divmod(a, b) ⇒ Object



235
236
237
# File 'lib/runar.rb', line 235

def divmod(a, b)
  Runar.divmod(a, b)
end

#ec_add(a, b) ⇒ Object

EC operations



290
291
292
# File 'lib/runar.rb', line 290

def ec_add(a, b)
  Runar::EC.ec_add(a, b)
end

#ec_encode_compressed(p) ⇒ Object



314
315
316
# File 'lib/runar.rb', line 314

def ec_encode_compressed(p)
  Runar::EC.ec_encode_compressed(p)
end

#ec_make_point(x, y) ⇒ Object



318
319
320
# File 'lib/runar.rb', line 318

def ec_make_point(x, y)
  Runar::EC.ec_make_point(x, y)
end

#ec_mod_reduce(value, m) ⇒ Object



310
311
312
# File 'lib/runar.rb', line 310

def ec_mod_reduce(value, m)
  Runar::EC.ec_mod_reduce(value, m)
end

#ec_mul(p, k) ⇒ Object



294
295
296
# File 'lib/runar.rb', line 294

def ec_mul(p, k)
  Runar::EC.ec_mul(p, k)
end

#ec_mul_gen(k) ⇒ Object



298
299
300
# File 'lib/runar.rb', line 298

def ec_mul_gen(k)
  Runar::EC.ec_mul_gen(k)
end

#ec_negate(p) ⇒ Object



302
303
304
# File 'lib/runar.rb', line 302

def ec_negate(p)
  Runar::EC.ec_negate(p)
end

#ec_on_curve(p) ⇒ Object



306
307
308
# File 'lib/runar.rb', line 306

def ec_on_curve(p)
  Runar::EC.ec_on_curve(p)
end

#ec_point_x(p) ⇒ Object



322
323
324
# File 'lib/runar.rb', line 322

def ec_point_x(p)
  Runar::EC.ec_point_x(p)
end

#ec_point_y(p) ⇒ Object



326
327
328
# File 'lib/runar.rb', line 326

def ec_point_y(p)
  Runar::EC.ec_point_y(p)
end

#extract_amount(preimage) ⇒ Object



269
270
271
# File 'lib/runar.rb', line 269

def extract_amount(preimage)
  Runar.extract_amount(preimage)
end

#extract_hash_prevouts(preimage) ⇒ Object



281
282
283
# File 'lib/runar.rb', line 281

def extract_hash_prevouts(preimage)
  Runar.extract_hash_prevouts(preimage)
end

#extract_locktime(preimage) ⇒ Object

Preimage extraction



261
262
263
# File 'lib/runar.rb', line 261

def extract_locktime(preimage)
  Runar.extract_locktime(preimage)
end

#extract_outpoint(preimage) ⇒ Object



285
286
287
# File 'lib/runar.rb', line 285

def extract_outpoint(preimage)
  Runar.extract_outpoint(preimage)
end

#extract_output_hash(preimage) ⇒ Object



265
266
267
# File 'lib/runar.rb', line 265

def extract_output_hash(preimage)
  Runar.extract_output_hash(preimage)
end

#extract_sequence(preimage) ⇒ Object



277
278
279
# File 'lib/runar.rb', line 277

def extract_sequence(preimage)
  Runar.extract_sequence(preimage)
end

#extract_version(preimage) ⇒ Object



273
274
275
# File 'lib/runar.rb', line 273

def extract_version(preimage)
  Runar.extract_version(preimage)
end

#gcd(a, b) ⇒ Object



231
232
233
# File 'lib/runar.rb', line 231

def gcd(a, b)
  Runar.gcd(a, b)
end

#hash160(data) ⇒ Object

Hash functions



88
89
90
# File 'lib/runar.rb', line 88

def hash160(data)
  Runar.hash160(data)
end

#hash256(data) ⇒ Object



92
93
94
# File 'lib/runar.rb', line 92

def hash256(data)
  Runar.hash256(data)
end

#left(data, length) ⇒ Object



182
183
184
# File 'lib/runar.rb', line 182

def left(data, length)
  Runar.left(data, length)
end

#len(data) ⇒ Object



194
195
196
# File 'lib/runar.rb', line 194

def len(data)
  Runar.len(data)
end

#log2(n) ⇒ Object



239
240
241
# File 'lib/runar.rb', line 239

def log2(n)
  Runar.log2(n)
end

#mock_preimageObject



256
257
258
# File 'lib/runar.rb', line 256

def mock_preimage
  Runar.mock_preimage
end

#mock_pub_keyObject



252
253
254
# File 'lib/runar.rb', line 252

def mock_pub_key
  Runar.mock_pub_key
end

#mock_sigObject

Test helpers



248
249
250
# File 'lib/runar.rb', line 248

def mock_sig
  Runar.mock_sig
end

#mul_div(a, b, c) ⇒ Object



219
220
221
# File 'lib/runar.rb', line 219

def mul_div(a, b, c)
  Runar.mul_div(a, b, c)
end

#num2bin(v, length) ⇒ Object

Binary utilities



166
167
168
# File 'lib/runar.rb', line 166

def num2bin(v, length)
  Runar.num2bin(v, length)
end

#percent_of(amount, bps) ⇒ Object



223
224
225
# File 'lib/runar.rb', line 223

def percent_of(amount, bps)
  Runar.percent_of(amount, bps)
end

#pow(base, exp) ⇒ Object



215
216
217
# File 'lib/runar.rb', line 215

def pow(base, exp)
  Runar.pow(base, exp)
end

#reverse_bytes(data) ⇒ Object



190
191
192
# File 'lib/runar.rb', line 190

def reverse_bytes(data)
  Runar.reverse_bytes(data)
end

#right(data, length) ⇒ Object



186
187
188
# File 'lib/runar.rb', line 186

def right(data, length)
  Runar.right(data, length)
end

#ripemd160(data) ⇒ Object



100
101
102
# File 'lib/runar.rb', line 100

def ripemd160(data)
  Runar.ripemd160(data)
end

#safediv(a, b) ⇒ Object

Math



199
200
201
# File 'lib/runar.rb', line 199

def safediv(a, b)
  Runar.safediv(a, b)
end

#safemod(a, b) ⇒ Object



203
204
205
# File 'lib/runar.rb', line 203

def safemod(a, b)
  Runar.safemod(a, b)
end

#sha256(data) ⇒ Object



96
97
98
# File 'lib/runar.rb', line 96

def sha256(data)
  Runar.sha256(data)
end

#sha256_compress(state, block) ⇒ Object



149
150
151
# File 'lib/runar.rb', line 149

def sha256_compress(state, block)
  Runar.sha256_compress(state, block)
end

#sha256_finalize(state, remaining, msg_bit_len) ⇒ Object



153
154
155
# File 'lib/runar.rb', line 153

def sha256_finalize(state, remaining, msg_bit_len)
  Runar.sha256_finalize(state, remaining, msg_bit_len)
end

#sign(n) ⇒ Object



211
212
213
# File 'lib/runar.rb', line 211

def sign(n)
  Runar.sign(n)
end

#sqrt(n) ⇒ Object



227
228
229
# File 'lib/runar.rb', line 227

def sqrt(n)
  Runar.sqrt(n)
end

#substr(data, start, length) ⇒ Object



178
179
180
# File 'lib/runar.rb', line 178

def substr(data, start, length)
  Runar.substr(data, start, length)
end

#verify_rabin_sig(msg, sig, padding, pk) ⇒ Object



117
118
119
# File 'lib/runar.rb', line 117

def verify_rabin_sig(msg, sig, padding, pk)
  Runar.verify_rabin_sig(msg, sig, padding, pk)
end

#verify_slh_dsa_sha2_128f(msg, sig, pubkey) ⇒ Object



129
130
131
# File 'lib/runar.rb', line 129

def verify_slh_dsa_sha2_128f(msg, sig, pubkey)
  Runar.verify_slh_dsa_sha2_128f(msg, sig, pubkey)
end

#verify_slh_dsa_sha2_128s(msg, sig, pubkey) ⇒ Object



125
126
127
# File 'lib/runar.rb', line 125

def verify_slh_dsa_sha2_128s(msg, sig, pubkey)
  Runar.verify_slh_dsa_sha2_128s(msg, sig, pubkey)
end

#verify_slh_dsa_sha2_192f(msg, sig, pubkey) ⇒ Object



137
138
139
# File 'lib/runar.rb', line 137

def verify_slh_dsa_sha2_192f(msg, sig, pubkey)
  Runar.verify_slh_dsa_sha2_192f(msg, sig, pubkey)
end

#verify_slh_dsa_sha2_192s(msg, sig, pubkey) ⇒ Object



133
134
135
# File 'lib/runar.rb', line 133

def verify_slh_dsa_sha2_192s(msg, sig, pubkey)
  Runar.verify_slh_dsa_sha2_192s(msg, sig, pubkey)
end

#verify_slh_dsa_sha2_256f(msg, sig, pubkey) ⇒ Object



145
146
147
# File 'lib/runar.rb', line 145

def verify_slh_dsa_sha2_256f(msg, sig, pubkey)
  Runar.verify_slh_dsa_sha2_256f(msg, sig, pubkey)
end

#verify_slh_dsa_sha2_256s(msg, sig, pubkey) ⇒ Object



141
142
143
# File 'lib/runar.rb', line 141

def verify_slh_dsa_sha2_256s(msg, sig, pubkey)
  Runar.verify_slh_dsa_sha2_256s(msg, sig, pubkey)
end

#verify_wots(msg, sig, pubkey) ⇒ Object



121
122
123
# File 'lib/runar.rb', line 121

def verify_wots(msg, sig, pubkey)
  Runar.verify_wots(msg, sig, pubkey)
end

#within(x, lo, hi) ⇒ Object



207
208
209
# File 'lib/runar.rb', line 207

def within(x, lo, hi)
  Runar.within(x, lo, hi)
end