How can I implement this in C++ or VB.net?

Click For Summary

Discussion Overview

The discussion revolves around the implementation of the Ong-Schnorr signature scheme in C++ or VB.net. Participants explore the mathematical foundations of the scheme, particularly focusing on the calculations involving modular arithmetic and the generation of random integers that are relatively prime to a given integer n.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant seeks clarification on interpreting the inverse random integer k in the context of the Ong-Schnorr signature scheme, expressing uncertainty due to their background in electronics.
  • Another participant provides a brief overview of how to generate random numbers in C using the stdlib function rand(), but does not directly address the signature scheme.
  • A different participant challenges the examples provided, indicating a lack of understanding of finite field math and presenting tables for addition, subtraction, multiplication, and division in modulo 5.
  • There is a discussion about the calculations for h and the verification of the signature, with one participant questioning the correctness of their interpretation of k's inverse.
  • Another participant explains the process of finding the inverse in finite fields, suggesting the use of logarithms and table lookups for calculations involving modular arithmetic.

Areas of Agreement / Disagreement

Participants express varying levels of understanding regarding the mathematical concepts involved, and there is no consensus on the interpretation of the examples or the implementation details of the signature scheme. Multiple competing views and uncertainties remain throughout the discussion.

Contextual Notes

The discussion includes unresolved mathematical steps and assumptions regarding the properties of integers and modular arithmetic. Specific dependencies on definitions of terms like "relatively prime" and "inverse" are not fully clarified.

bhardjono
Messages
2
Reaction score
0
Please help - I am helping a student who is trying to translate Ong-Schnorr to C++ or VB.net language. My major was electronics so I am not sure how to interpret inverse random integer k. Any one ? or suggest me a reference to read on - much thanks, newbie

Ong-Schnorr-Shamir (from Briuce's Applied Cryptography p.418 chp 20.5)
This signature scheme uses polynomials modulo n [1219,1220]. Choose a large integer n (you need not know the factorization of n). Then choose a random integer, k, such that k and n are relatively prime. Calculate h such that
h = –k^-2 mod n = -(k^-1)^2 mod n
The public key is h and n; k is the private key.
To sign a message, M, first generate a random number, r, such that r and n are relatively prime. Then calculate:

S1 = 1/2 * (M/r + r) mod n
S2 = k/2 * (M/r – r) mod n
The pair, S1 and S2, is the signature.
To verify a signature, confirm that
S1^2 + h * S2^2 identical to M (mod n)
 
Technology news on Phys.org
bhardjono said:
Please help - I am helping a student who is trying to translate Ong-Schnorr to C++ or VB.net language. My major was electronics so I am not sure how to interpret inverse random integer k. Any one ? or suggest me a reference to read on - much thanks, newbie

Ong-Schnorr-Shamir (from Briuce's Applied Cryptography p.418 chp 20.5)
This signature scheme uses polynomials modulo n [1219,1220]. Choose a large integer n (you need not know the factorization of n). Then choose a random integer, k, such that k and n are relatively prime. Calculate h such that
h = –k^-2 mod n = -(k^-1)^2 mod n
The public key is h and n; k is the private key.
To sign a message, M, first generate a random number, r, such that r and n are relatively prime. Then calculate:

S1 = 1/2 * (M/r + r) mod n
S2 = k/2 * (M/r – r) mod n
The pair, S1 and S2, is the signature.
To verify a signature, confirm that
S1^2 + h * S2^2 identical to M (mod n)
3 mod 10 = 3
4 mod 10 = 4
10 mod 3 = 1
10 mod 4 = 2

in Schnorr
h= -k^(-2) mod n
h= -(k^(-1))^2 mod n
Hence for 2 primes
9 mod 2 = 1
(3)^2 mod 2 = 1
Therefore k^(-1) = 3 Is this right please your opinion please - thanks in advance
 
I'm not entirely clear what your question is, but if it's how to get a (sorta) random number in C... The stdlib has: int rand ( void ); which you can seed with srand(). A man page is here:
http://www.cplusplus.com/reference/clibrary/cstdlib/rand/
 
I don't know about encryption, but know a bit about finite field math and don't understand your examples. Using 5 as n, you get these tables for finite field math modulo 5:

Code:
add                   subtract (left - top)

   0  1  2  3  4         0  1  2  3  4
  --------------        --------------
0| 0  1  2  3  4      0| 0  4  3  2  1
1| 1  2  3  4  0      1| 1  0  4  3  2
2| 2  3  4  0  1      2| 2  1  0  4  3
3| 3  4  0  1  2      3| 3  2  2  0  4
4| 4  0  1  2  3      4| 4  3  2  1  0

multiply              divide (left / top)

   0  1  2  3  4         0  1  2  3  4
  --------------        --------------
0| 0  0  0  0  0      0| x  0  0  0  0
1| 0  1  2  3  4      1| x  1  3  2  4
2| 0  2  4  1  3      2| x  2  1  4  3
3| 0  3  1  4  2      3| x  3  4  1  2
4| 0  4  3  2  1      4| x  4  2  3  1

All non-zero numbers can be considered to be a power of 2. Multiply and divide can be peformed by taking the logs of finite field numbers and adding or subracting modulo 4 (n-1), the exponentiating the result. This doesn't work for all finite fields, in this case, 2 is a "primitive" for a finite field modulo 5.

20 = 1
21 = 2
22 = 4
23 = 3

In the general case of a finite field number to determine (-1/k)2 , you first find i = ( (0 - k) mod n). Then you need to do a table lookup, or implement an algorithm to solve for j where ((i x j) mod n) = 1, then 1/i = j. (1/i)2 would be ((j2) mod n).
 
Last edited:

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
Replies
9
Views
10K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 27 ·
Replies
27
Views
5K
  • · Replies 17 ·
Replies
17
Views
7K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 100 ·
4
Replies
100
Views
13K
  • · Replies 93 ·
4
Replies
93
Views
16K