Class: TweetNaCl::CryptoSign

Inherits:
Object
  • Object
show all
Defined in:
lib/tweetnacl/crypto_sign.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keypair = KeyPair.new(TweetNaCl.crypto_sign_keypair)) ⇒ CryptoSign

Returns a new instance of CryptoSign.



5
6
7
# File 'lib/tweetnacl/crypto_sign.rb', line 5

def initialize(keypair = KeyPair.new(TweetNaCl.crypto_sign_keypair))
  @keypair = keypair
end

Instance Attribute Details

#keypairObject (readonly)

Returns the value of attribute keypair.



3
4
5
# File 'lib/tweetnacl/crypto_sign.rb', line 3

def keypair
  @keypair
end

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/tweetnacl/crypto_sign.rb', line 3

def message
  @message
end

#signed_messageObject (readonly)

Returns the value of attribute signed_message.



3
4
5
# File 'lib/tweetnacl/crypto_sign.rb', line 3

def signed_message
  @signed_message
end

Instance Method Details

#sign(message) ⇒ Object



9
10
11
# File 'lib/tweetnacl/crypto_sign.rb', line 9

def sign(message)
  @signed_message = TweetNaCl.crypto_sign(message, @keypair.secret_key)
end

#verify(message) ⇒ Object



13
14
15
# File 'lib/tweetnacl/crypto_sign.rb', line 13

def verify(message)
  @message = TweetNaCl.crypto_sign_open(message.signed_message, @keypair.public_key)
end