Module: RSA::ACC::PoE

Extended by:
Functions
Includes:
Functions
Included in:
RSA::Accumulator
Defined in:
lib/rsa/acc/poe.rb

Overview

Non-Interactive Proof of Exponentiation

Class Method Summary collapse

Methods included from Functions

blake2_hash, compute_challenge, egcd, elements_to_prime, hash_to_prime, shamir_trick

Class Method Details

.prove(base, exp, result, modulus) ⇒ Object

Computes a proof base ^ H(exp) was performed to derive result.

Parameters:

  • base (Integer)

    The known base.

  • exp (Integer)

    The exponentiation.

  • result (Integer)

    such as result = base^exp.

  • modulus (Integer)

    modulus using computation.



19
20
21
22
23
# File 'lib/rsa/acc/poe.rb', line 19

def prove(base, exp, result, modulus)
  l = compute_challenge(base, exp, result)
  q = exp / l
  base.pow(q, modulus)
end

.verify(base, exp, result, proof, modulus) ⇒ Object

Verifies that base^exp = result using the given proof to avoid computation.

Parameters:

  • base (Integer)

    The known base.

  • exp (Integer)

    The exponentiation.

  • result (Integer)

    such as result = base^exp.

  • proof (Integer)

    an proof.

  • modulus (Integer)

    modulus using computation.



31
32
33
34
35
36
# File 'lib/rsa/acc/poe.rb', line 31

def verify(base, exp, result, proof, modulus)
  l = compute_challenge(base, exp, result)
  r = exp % l
  w = (proof.pow(l, modulus) * base.pow(r, modulus)) % modulus
  w == result
end