RFC9497 OPRF works + integrating output #1510
wmcelderry
started this conversation in
Show and tell
Replies: 2 comments 15 replies
-
|
The context can be binary (and therefore has a defined length), but are there protocols where the context is not a string? From what I’ve seen so far, H2C always uses a fixed string. More test vectors can be certainly be added to core_ed25519_h2c.c |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Yes, my understanding is the context is binary, not just the content. That is supported by the matching text vectors (assuming I haven't got matching test vectors through a very confusing bug!). Please do sanity check though! - a few explanatory excerpts from rfcs (click to unfold)RFC94973.13.1. Configuration
Each of the three protocol variants are identified with a one-byte
value (in hexadecimal):
+===========+=======+
| Mode | Value |
+===========+=======+
| modeOPRF | 0x00 |
+-----------+-------+
| modeVOPRF | 0x01 |
+-----------+-------+
| modePOPRF | 0x02 |
+-----------+-------+
Table 1: Identifiers
for Protocol Variants
Additionally, each protocol variant is instantiated with a
ciphersuite or suite. Each ciphersuite is identified with an ASCII
string identifier, referred to as identifier; see Section 4 for the
set of initial ciphersuite values.
The mode and ciphersuite identifier values are combined to create a
"context string" used throughout the protocol with the following
function:
def CreateContextString(mode, identifier):
return "OPRFV1-" || I2OSP(mode, 1) || "-" || identifier
1.21.2. Notation and Terminology
The following functions and notation are used throughout the
document.
...
* I2OSP(x, xLen) converts a nonnegative integer x into a byte array
of specified length xLen, as described in [RFC8017]. Note that
this function returns a byte array in big-endian byte order.
RFC8017[4.1](https://www.rfc-editor.org/rfc/rfc8017#section-4.1). I2OSP
I2OSP converts a nonnegative integer to an octet string of a
specified length.
I2OSP (x, xLen)
Input:
x nonnegative integer to be converted
xLen intended length of the resulting octet string
Output:
X corresponding octet string of length xLen
Error: "integer too large"
Steps:
1. If x >= 256^xLen, output "integer too large" and stop.
2. Write the integer x in its unique xLen-digit representation in
base 256:
x = x_(xLen-1) 256^(xLen-1) + x_(xLen-2) 256^(xLen-2) + ...
+ x_1 256 + x_0,
where 0 <= x_i < 256 (note that one or more leading digits
will be zero if x is less than 256^(xLen-1)).
|
Beta Was this translation helpful? Give feedback.
14 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi All,
Thanks for making and sharing such a useful repository!
I wanted to flag that I've followed the OPRF RFC 9497 and been able to achieve the (2!) test vector results for 'OPRF mode' with sodium using ristretto255 and the h2c functions on the master thread, and discuss how to feed back to the project.
It has involved one minor tweak to your code to get it matching the test vectors.
There are two things I think could be useful to the project:
masterbranch to take an extractx_lenparameter.While these are both trivial, if these are useful let me know and I'll explore how I can support.
More detail:
The h2c functions need an extra parameter: the length of the context 'string'. I have code, can share if useful.
The current implementation on the `master` branch calculates the string length using strlen/the null byte, but (frustratingly) the DST in the RFC9497 can have a null byte in the middle of the string for the OPRF mode (designated 'mode 0' and the `0` gets written as a binary byte in the middle of the DST - confirmed by matching output from the test vectors).ctx_lenparameter, but trivial to overload and chain the implementation)Are the test vectors useful? If so how should I make them available?
I saw another discussion saying test vectors are not available for ristretto255 H2C, but they are implied by the test vectors in RFC9497.This is true, the test vectors given are for known 'blinded' elements, with specified blinding factor, so not quite verbatim. It is trivial to recover the originals as the blind is given too. I can confirm that h2c must work (for ristretto255-SHA512) to get the blinded element, but what is the best (set) of tests?
Beta Was this translation helpful? Give feedback.
All reactions