This is a ruby libraray for Sr25519. Use to sign and verify message.
More info at: https://github.com/w3f/schnorrkel
Add this line to your application's Gemfile:
gem 'sr25519'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install sr25519
require "sr25519"
# seed is priviate key, is a hex string.
# example: SR25519.keypair_from_seed("0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e")
keypair = SR25519.keypair_from_seed(seed)
public_key = SR25519.get_public_key_from_seed(seed)
# get the hex string
public_key_str = public_key.to_s
address = Address.encode(public_key.to_s)
public_key_str = Address.decode(address)
# message = "Hello World"
signature_result = SR25519.sign(message, keypair)
verify_result = SR25519.verify(address, message, signature_result)
keypair = ED25519.keypair_from_seed(seed)
signature_result = ED25519.sign(message, keypair)
pulick_key_str = ED25519.get_public_key_from_seed(seed)
# public_key_str = ED25519.get_public_key_from_seed(seed)
# address = Address.encode(public_key_str)
verify_result = ED25519.verify(address, message, signature_result)
- Run all tests
rspec
-
Update to latest image
docker pull uniart/sr25519:latest
-
Run image:
docker run -it uniart/sr25519:latest bash
This will enter the container with a linux shell opened.
/usr/src/app #
-
Type
rspec
to run all tests/usr/src/app # rspec
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/uni-arts-chain/sr25519. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.