Module: Crypto::ScalarMult
- Extended by:
- FFI::Library, Sodium::Utils
- Defined in:
- lib/crypto/scalar_mult.rb
Constant Summary collapse
- PRIMITIVE =
primitive.freeze
- BYTES =
bytes.freeze
- SCALARBYTES =
scalarbytes.freeze
Constants included from Sodium::Utils
Sodium::Utils::HEXY, Sodium::Utils::ZERO
Class Method Summary collapse
Methods included from Sodium::Utils
bin2hex, check_length, get_size, hex2bin, zeros
Class Method Details
.base(secret_key) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/crypto/scalar_mult.rb', line 25 def base(secret_key) check_length(secret_key, SCALARBYTES, :SecretKey) public_key = zeros(BYTES) secret_key.readonly if secret_key.is_a?(Sodium::SecretBuffer) crypto_scalarmult_base(public_key, secret_key) public_key ensure secret_key.noaccess if secret_key.is_a?(Sodium::SecretBuffer) end |
.scalarmut(secret_key, public_key) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/crypto/scalar_mult.rb', line 37 def scalarmut(secret_key, public_key) check_length(secret_key, SCALARBYTES, :SecretKey) check_length(public_key, BYTES, :PublicKey) shared_secret = Sodium::SecretBuffer.new(BYTES) secret_key.readonly if secret_key.is_a?(Sodium::SecretBuffer) crypto_scalarmult(shared_secret, secret_key, public_key) shared_secret.noaccess shared_secret ensure secret_key.noaccess if secret_key.is_a?(Sodium::SecretBuffer) end |