Sha256: d69432b7596b1791fadbfda774d11ba30dc4d099babd56dbfa96282b1c861b0f
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
# encoding: ascii-8bit require_relative 'spec_helper.rb' require 'bitcoin' describe 'libsecp256k1' do it 'generate key pair' do priv, pub = Bitcoin::Secp256k1.generate_key_pair(compressed = true) [priv, pub].map(&:bytesize).should == [32, 33] ["\x03", "\x02"].include?(pub[0]).should == true priv, pub = Bitcoin::Secp256k1.generate_key_pair(compressed = false) [priv, pub].map(&:bytesize).should == [32, 65] ["\x04"].include?(pub[0]).should == true end it 'generate key' do key = Bitcoin::Secp256k1.generate_key(compressed = true) key.compressed.should == true key = Bitcoin::Secp256k1.generate_key(compressed = false) key.compressed.should == false end it 'sign and verify' do priv, pub = Bitcoin::Secp256k1.generate_key_pair signature = Bitcoin::Secp256k1.sign("derp", priv) Bitcoin::Secp256k1.verify("derp", signature, pub).should == true end it 'sign compact and recover' do priv, pub = Bitcoin::Secp256k1.generate_key_pair(compressed=true) signature = Bitcoin::Secp256k1.sign_compact("derp", priv, compressed=true) signature.bytesize.should == 65 pub2 = Bitcoin::Secp256k1.recover_compact("derp", signature) pub2.bytesize.should == 33 pub2.should == pub # uncompressed priv, pub = Bitcoin::Secp256k1.generate_key_pair(compressed=false) signature = Bitcoin::Secp256k1.sign_compact("derp", priv, compressed=false) signature.bytesize.should == 65 pub2 = Bitcoin::Secp256k1.recover_compact("derp", signature) pub2.bytesize.should == 65 pub2.should == pub end it 'deterministic signature using rfc6979' do priv, pub = Bitcoin::Secp256k1.generate_key_pair first = Bitcoin::Secp256k1.sign("derp", priv) second = Bitcoin::Secp256k1.sign("derp", priv) first.should == second end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bitcoin-ruby-0.0.9 | spec/bitcoin/secp256k1_spec.rb |
bitcoin-ruby-0.0.8 | spec/bitcoin/secp256k1_spec.rb |