Re: [Cfrg] Field Element Format

Paul Lambert <> Tue, 27 January 2015 20:43 UTC

Return-Path: <>
Received: from localhost ( []) by (Postfix) with ESMTP id 5664A1A8AA1 for <>; Tue, 27 Jan 2015 12:43:06 -0800 (PST)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -1.667
X-Spam-Status: No, score=-1.667 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, IP_NOT_FRIENDLY=0.334, J_CHICKENPOX_45=0.6, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=no
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id AHmebLbk7OWU for <>; Tue, 27 Jan 2015 12:43:04 -0800 (PST)
Received: from ( []) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by (Postfix) with ESMTPS id B01C31A8A8C for <>; Tue, 27 Jan 2015 12:43:04 -0800 (PST)
Received: from pps.filterd ( []) by (8.14.5/8.14.5) with SMTP id t0RKcpDO023667 for <>; Tue, 27 Jan 2015 12:43:04 -0800
Received: from ([]) by with ESMTP id 1s49rxys6e-5 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for <>; Tue, 27 Jan 2015 12:43:04 -0800
Received: from ([]) by ([::1]) with mapi; Tue, 27 Jan 2015 12:43:02 -0800
From: Paul Lambert <>
To: "''" <>
Date: Tue, 27 Jan 2015 12:43:00 -0800
Thread-Topic: [Cfrg] Field Element Format
Thread-Index: AdA6cdd9oMYFS/WFRY6Qs+s7fxcB2Q==
Message-ID: <>
Accept-Language: en-US
Content-Language: en-US
user-agent: Microsoft-MacOutlook/
acceptlanguage: en-US
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68, 1.0.33, 0.0.0000 definitions=2015-01-27_03:2015-01-27, 2015-01-26, 1970-01-01 signatures=0
X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1501270203
Archived-At: <>
Subject: Re: [Cfrg] Field Element Format
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Crypto Forum Research Group <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Tue, 27 Jan 2015 20:43:06 -0000

I think that Dan Harkins had a good point about the need for clarity about
both the internal and external structure of an octet string representing a

Issue: Specifications MUST prescribe octet-string format for all
       applications of a field element (not just over-the-wire)

A specific recommendation would be to define not just the Œwire-format¹ of
field elements, but to be very specific that that both wire-format
and any other protocol usage of the field element as a octet string
must be in the prescribed encoding format.

Current text:
>Wire-format of field elements
>When transmitting field elements in the Diffie-Hellman protocol below,
>MUST be encoded as an array of bytes, x, in Š

Suggested change:
< Octet-string format of field elements
< Field elements are converted to a string of octets for transmission in
< the Diffie-Hellman protocol below and for other cryptographic
< protocol uses and operations that are not performed on Gfp
< (e.g. Hash(field element). When converting a field element
< to an octet-string, the field element
< MUST be encoded as an array of bytes x, in Š

Note that the text above is independent of the endian, I left that out ...


PS - whoever is moderating this discussion, would you please add this to
your tracking list as an editorial comment to review and determine
if action or not is required.  Since we are supposedly Œreviewing¹
a document, tracking and clear resolution of topics
would be valuable. 

It would be of great value to publish the list so that
we could have a clear burn-down list to reach an end.

On 1/27/15, 11:56 AM, "Michael Clark" <> wrote:

>On 27/1/15 6:34 pm, Peter Gutmann wrote:
>> Michael Clark <> writes:
>>> This code could do with some optimization, bswap(32|64) intrinsic
>>>(uses BSWAP
>>> machine instruction on x86_64, ARM, etc), working with a machine word
>>> loop with a small tail loop to handle the modulus of the difference in
>>> of the bignum from the machine word size. It is working byte by byte.
>> This is another example of "I can't believe we're having this
>> We're talking about bignum operations measured in the millions of CPU
>> (a basic 1024-bit RSA decrypt is about 10M cycles, with P256 it's 7M
>> courtesy of the Crypto++ benchmark data) and you're bringing up
>> something that might take a few hundred cycles (ignoring memory latency
>> overhead, which is going to hit you at some point whether you
>> or not).
>> The issue isn't about whether a 0.001% overhead is worth applying custom
>> architecture-specific assembly-language to eliminate, it's the issue of
>> encoding a particular implementation artefact into a standard.  As djb
>> helpfully pointed out, he could have decided to encode the values as
>> decimal digits, or perhaps doodles, sign language, and squirrel noises.
>> Would
>> crypto standards then require that everything using 25519 be able to
>> the output as squirrel noises just because that's what one
>> does?
>> The universal standard for crypto bignums is big-endian (things like
>> aren't a standard, it's what one
>> chooses to do).  The 25519 form is an implementation artefact and
>>should have
>> no place in a standard.
>I agree. I did qualify the statement that its unlikely to register on a
>profile. e.g. don't forget to paraphrase without the context:
>On 26/1/15 8:57 pm, Michael Clark wrote:
>> So with big-endian wire-formats, practically all machines are going to
>> bswap as the internal rep will be little endian. That cost is probably
>> low compared to the cost of the computation, so there is a reasonable
>> rationale to stick to big-endian.
>This seems to be about adapting to IETF tradition. Fair enough.
>The question is whether or not in the case of Curve25519, the keys are
>considered an "opaque octet string" or unless the point needs to be
>consumed and interpreted outside of the cryptographic primitive; then
>there is an argument to follow the big-endian bignum tradition.
>1). Will Curve25519 be used elsewhere (other than as a diffie-hellman
>replacement) where the keys are exposed in form they need to be operated
>on as a bignum, rather than opaque 32-byte octet strings? i.e. is to be
>considered a standalone cryptographic primitive?
>2). From reading Curve25519, the keys are stated as opaque, however I
>understand that Curve25519 can be expressed in various isogenies where
>the keys (32-byte strings) are no longer opaque and are big-nums. Is it
>intended to be used in a general way as a parametrization?
>If so it would mean it might be a good idea either for Curve25519 to use
>byteswap from network byte order or to define a big-endian alternative
>with a different name that does so. X25519; where the keys are no longer
>opaque as per the current normative reference that specifies
>"little-endian" 32-byte strings:
>a). If it is intended to be used as a standalone primitive, then it
>doesn't matter so much: "32-byte octet string"
>b). However if it is to be used generally as a parametrization that fits
>into a curve generalization then this provides a good rationale to use
>the tradition of big-endian bignums. i.e. ends up in ASN.1 fields, with
>different parametrization of the same generalization.
>Does that make it any easier? :-)
>Cfrg mailing list