Sha256: c2fc251e772ccef8bc2bb85b661accb0169005b1907a6e2c3b82bf6fb10e2d9f
Contents?: true
Size: 716 Bytes
Versions: 1
Compression:
Stored size: 716 Bytes
Contents
# frozen_string_literal: true require "securerandom" module Ed25519 # Private key for producing digital signatures class SigningKey attr_reader :verify_key def self.generate new SecureRandom.random_bytes(Ed25519::SECRET_KEY_BYTES) end def initialize(seed) raise ArgumentError, "seed must be 32 bytes long" unless seed.length == SECRET_KEY_BYTES @seed = seed verify_key, @signing_key = Ed25519::Engine.create_keypair(seed) @verify_key = VerifyKey.new(verify_key) end def sign(message) Ed25519::Engine.sign(@signing_key, message) end def inspect to_s end def to_bytes @seed end alias to_str to_bytes end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ed25519-0.1.0 | lib/ed25519/signing_key.rb |