<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>23445</bug_id>
          
          <creation_ts>2013-10-07 10:05:19 +0000</creation_ts>
          <short_desc>typo with BigInteger?</short_desc>
          <delta_ts>2014-01-28 18:44:02 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Web Cryptography</product>
          <component>Web Cryptography API Document</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Franz Antesberger">info</reporter>
          <assigned_to name="Mark Watson">watsonm</assigned_to>
          <cc>ap</cc>
    
    <cc>info</cc>
    
    <cc>watsonm</cc>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>94386</commentid>
    <comment_count>0</comment_count>
    <who name="Franz Antesberger">info</who>
    <bug_when>2013-10-07 10:05:19 +0000</bug_when>
    <thetext>16. BigInteger reads &quot;A leading zero Uint8 element is not needed if the most significant bit of the integer is set.&quot;
Shouldn&apos;t it be the other way around,
&quot;A leading zero Uint8 element is not needed if the most significant bit of the integer is NOT set.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98918</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-01-23 00:44:42 +0000</bug_when>
    <thetext>(In reply to Franz Antesberger from comment #0)
&gt; 16. BigInteger reads &quot;A leading zero Uint8 element is not needed if the most
&gt; significant bit of the integer is set.&quot;
&gt; Shouldn&apos;t it be the other way around,
&gt; &quot;A leading zero Uint8 element is not needed if the most significant bit of
&gt; the integer is NOT set.&quot;

I don&apos;t think that sentence is required at all. The rest of the definition is unambiguous, although &quot;multiple-precision&quot; could be replaced with &quot;arbitrary magnitude&quot; (integers have exactly the &apos;precision&apos; that they have, nothing else).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99090</commentid>
    <comment_count>2</comment_count>
    <who name="Franz Antesberger">info</who>
    <bug_when>2014-01-25 21:22:58 +0000</bug_when>
    <thetext>We have two things to be considered:
1) What do we need for a minimum?
2) What do all the others?
First to 2)
All the others (bouncy castle, openssl)
- use big endian (as here)
- use leading zeros, when the high bit is set
- leading zeros are done bytewise, not wordwise
2nd to 1)
what should we do here?
- I think, BigInteger should be bound to ArrayBuffer, not to Uint8Array. Calculation with Uint32Arrays is MUCH faster.
- big endian is nice, but all the BigInt-Libs I know use little endian, is that an issue? We could easily build a wrapper
- X.509 Certificates use little endian, byte arrays and leading zeros, if high byte &gt;= 0x80.

I completely agree with your &quot;multiple-precision&quot; argument.

I think, we have two ways:
a) we could replace &quot;BigInteger&quot; with &quot;BigUnsignedInteger&quot; -- then no leading zeros are needed. But the name does not sound well.
b) we could use &quot;BigInteger&quot;, but then please with leading zeros, if leading &gt;= 0x80.

I will try to make a complete proposal for this chapter next weekend</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99164</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-01-27 16:41:51 +0000</bug_when>
    <thetext>(In reply to Franz Antesberger from comment #2)
&gt; We have two things to be considered:
&gt; 1) What do we need for a minimum?
&gt; 2) What do all the others?
&gt; First to 2)
&gt; All the others (bouncy castle, openssl)
&gt; - use big endian (as here)
&gt; - use leading zeros, when the high bit is set
&gt; - leading zeros are done bytewise, not wordwise
&gt; 2nd to 1)
&gt; what should we do here?
&gt; - I think, BigInteger should be bound to ArrayBuffer, not to Uint8Array.
&gt; Calculation with Uint32Arrays is MUCH faster.
&gt; - big endian is nice, but all the BigInt-Libs I know use little endian, is
&gt; that an issue? We could easily build a wrapper
&gt; - X.509 Certificates use little endian, byte arrays and leading zeros, if
&gt; high byte &gt;= 0x80.
&gt; 
&gt; I completely agree with your &quot;multiple-precision&quot; argument.
&gt; 
&gt; I think, we have two ways:
&gt; a) we could replace &quot;BigInteger&quot; with &quot;BigUnsignedInteger&quot; -- then no
&gt; leading zeros are needed. But the name does not sound well.
&gt; b) we could use &quot;BigInteger&quot;, but then please with leading zeros, if leading
&gt; &gt;= 0x80.
&gt; 
&gt; I will try to make a complete proposal for this chapter next weekend

- it seems safer to stick with big endian, since that is what we have had since the beginning
- switching to ArrayBuffer is another issue (I filed bug 24409)
- I don&apos;t understand the need for the leading 0x00 - it just introduces an error case that need not exist. I do understand why we might want to highlight to implementors that the top bit is not a sign bit, because this is an unsigned integer. A note would be sufficient for this, rather than a normative requirement.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99178</commentid>
    <comment_count>4</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-01-27 19:06:25 +0000</bug_when>
    <thetext>I propose replacing the existing text of this section with:

&quot;The BigInteger typedef is a Uint8Array that holds a arbitrary magnitude unsigned integer in big-endian order.

Implementation note: Since the integer is unsigned, the highest order bit is NOT a sign bit. Implementors should take care when mapping to big integer implementations that expected signed integers.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99210</commentid>
    <comment_count>5</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-01-27 22:55:23 +0000</bug_when>
    <thetext>As discussed on call 1/27, we will require values read from the API to be in cannonical (most compact) form and will be tolerant of leading zero bits when values are passed to the API:

&quot;The BigInteger typedef is a Uint8Array that holds a arbitrary magnitude unsigned integer in big-endian order. Values read from the API SHALL have minimal typed array length (that is, at most 7 leading zero bits). The API SHALL accept values with any number of leading zero bits.

Implementation note: Since the integer is unsigned, the highest order bit is NOT a sign bit. Implementors should take care when mapping to big integer implementations that expected signed integers.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99212</commentid>
    <comment_count>6</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-01-27 23:05:21 +0000</bug_when>
    <thetext>As discussed on call 1/27, we will require values read from the API to be in cannonical (most compact) form and will be tolerant of leading zero bits when values are passed to the API:

&quot;The BigInteger typedef is a Uint8Array that holds a arbitrary magnitude unsigned integer in big-endian order. Values read from the API SHALL have minimal typed array length (that is, at most 7 leading zero bits, except the value 0 which shall have length 8 bits). The API SHALL accept values with any number of leading zero bits.

Implementation note: Since the integer is unsigned, the highest order bit is NOT a sign bit. Implementors should take care when mapping to big integer implementations that expected signed integers.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99224</commentid>
    <comment_count>7</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-01-28 00:15:18 +0000</bug_when>
    <thetext>https://dvcs.w3.org/hg/webcrypto-api/rev/33a21d9f624a</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99323</commentid>
    <comment_count>8</comment_count>
    <who name="Franz Antesberger">info</who>
    <bug_when>2014-01-28 18:20:30 +0000</bug_when>
    <thetext>I think, it is a bad idea to restrict to unsigned -- there are a lot of funny things you can do with the Chineese Reminder Theorem, but there you need signed integers.
And I think, it is a worse idea, calling it &quot;BigInteger&quot;, when it is unsigned. All the Typed Arrays use a &quot;U&quot;, when unsigned. So if restricting to unsigned, it should be renamed to &quot;BigUInteger&quot;. One day we might need signed BigIntegers.
For now we just store RSA-Keys, which really are unsigned

The leading zeros come from the ASN.1 INTEGER type, see e.g. http://luca.ntop.org/Teaching/Appunti/asn1.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99329</commentid>
    <comment_count>9</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-01-28 18:38:04 +0000</bug_when>
    <thetext>(In reply to Franz Antesberger from comment #8)
&gt; I think, it is a bad idea to restrict to unsigned -- there are a lot of
&gt; funny things you can do with the Chineese Reminder Theorem, but there you
&gt; need signed integers.
&gt; And I think, it is a worse idea, calling it &quot;BigInteger&quot;, when it is
&gt; unsigned. All the Typed Arrays use a &quot;U&quot;, when unsigned. So if restricting
&gt; to unsigned, it should be renamed to &quot;BigUInteger&quot;. One day we might need
&gt; signed BigIntegers.
&gt; For now we just store RSA-Keys, which really are unsigned
&gt; 

I think you should raise a new bug &quot;Make BigInteger signed or rename it&quot; for this issue.

&gt; The leading zeros come from the ASN.1 INTEGER type, see e.g.
&gt; http://luca.ntop.org/Teaching/Appunti/asn1.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99331</commentid>
    <comment_count>10</comment_count>
    <who name="Franz Antesberger">info</who>
    <bug_when>2014-01-28 18:44:02 +0000</bug_when>
    <thetext>Done, see https://www.w3.org/Bugs/Public/show_bug.cgi?id=24430</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>