Module: Ed25519::Engine
- Defined in:
- lib/red25519/jruby_engine.rb,
ext/red25519/red25519_engine.c
Class Method Summary collapse
- .create_keypair(seed) ⇒ Object
- .sign(signing_key, message) ⇒ Object
- .verify(verify_key, signature, message) ⇒ Object
Class Method Details
.create_keypair(seed) ⇒ Object
7 8 9 10 11 12 13 |
# File 'ext/red25519/red25519_engine.c', line 7 def create_keypair(seed) raise ArgumentError, "seed must be 32 bytes long" unless seed.length == 32 verify_key = org.red25519.ed25519.publickey(seed.to_java_bytes) verify_key = String.from_java_bytes(verify_key) [verify_key, seed + verify_key] end |
.sign(signing_key, message) ⇒ Object
8 9 10 11 12 13 14 |
# File 'ext/red25519/red25519_engine.c', line 8 def sign(signing_key, ) verify_key = signing_key[32...64].to_java_bytes signing_key = signing_key[0...32].to_java_bytes signature = org.red25519.ed25519.signature(.to_java_bytes, signing_key, verify_key) String.from_java_bytes(signature) end |
.verify(verify_key, signature, message) ⇒ Object
9 10 11 |
# File 'ext/red25519/red25519_engine.c', line 9 def verify(verify_key, signature, ) org.red25519.ed25519.checkvalid(signature.to_java_bytes, .to_java_bytes, verify_key.to_java_bytes) end |