Browse Source

PIP-0027: support account names and cleanup

Herman Schoenfeld 6 years ago
parent
commit
fc5fb58c24
1 changed files with 47 additions and 16 deletions
  1. 47 16
      PIP/PIP-0027.md

+ 47 - 16
PIP/PIP-0027.md

@@ -29,8 +29,11 @@ Layer-2 addresses will be herein referred to as Extended PASA, or E-PASA for sho
 
 An Extended PASA is defined by the below EBNF grammar:
 
+```
     EPASA              = PASA, [ ExtendedAddress ] ;
-    PASA               = Integer, "-", Checksum ;
+    PASA               = ( AccountName | AccountNumber ) ;
+    AccountName        = Pascal64String 
+    AccountNumber      = Integer, "-", Checksum ;
     Checksum           = Digit, Digit ;
     ExtendedAddress    = ( PublicPayload | ReceiverEncPayload | SenderEncPayload | PasswordEncPayload ), [ ":", PayloadChecksum ] ;
     PublicPayload      = "[", Payload, "]" ;
@@ -38,25 +41,29 @@ An Extended PASA is defined by the below EBNF grammar:
     SenderEncPayload   = "<", Payload, ">" ;
     PasswordEncPayload = "{", Payload, ":", Password, "}" ;
     Payload            = [ """, SafeAnsiString, """ | HexString | Base58String ] ;      (* allows empty payload *)
-    PayloadChecksum    = HexDigit, HexDigit, HexDigit, HexDigit
+    PayloadChecksum    = HexByte, HexByte
     Password           = SafeAnsiString
-    SafeAnsiString     = Pascal64StartChar, { Pascal64Char } ;
+    SafeAnsiString     = SafeAnsiChar, { SafeAnsiChar } ;
     SafeAnsiChar       = (" " | "!" | EscapeChar """ | "#" | "$" | "%" | "&" | "'" | "(" | ")" | "*" | "+" | "," | "-" | "." | "/" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | ":" | ";" | "<" | "=" | ">" | "?" | "@" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "[" | EscapeChar "\" | "]" | "^" | "_" | "`" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "{" | "|" | EscapeChar "}" | "~") ;
+    Pascal64String     = SafePascal64Char, {Pascal64Char}
+    Pascal64Char       = (Digit | SafePascal64Char)
+    SafePascal64Char   = ( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "+", "{", "}", "[", "]", "_", ":", "`", "|", "<", ">", ",", ".", "?", "/", "~", ")" "-", "+", "{", "}", "[", "]", "_", ":", "`", "|", "<", ">", ",", ".", "?", "/", "~" ) ; 
     HexString          = "0", "x", HexByte { HexByte } ;
-    HexByte            = HexDigit, HexDigit
-    HexDigit           = ( Digit | "a" | "b" | "c" | "d" | "e" | "f" ) ;       (* no uppercase hex allowed *)
+    HexByte            = HexNibble, HexNibble ;
+    HexNibble          = ( Digit | "a" | "b" | "c" | "d" | "e" | "f" ) ;       (* no uppercase hex allowed *)
     Base58String       = Base58Char, { Base58Char } ;
     Base58Char         = ( NaturalDigit | Base58UpperChar | Base58LowerChar ) ; 
     Base58UpperChar    = ( "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" ) ;     (* missing I, O *)
     Base58LowerChar    = ( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ) ; (* missing l *)
     Digit              = ( "0" | NaturalDigit ) ;
     NaturalDigit       = ( "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ) ;
-    EscapeChar         = "\"
+    EscapeChar         = "\" ;
+```
 
 | Rule               | Explanation                                                                                                   |
 | -----------------: | :------------------------------------------------------------------------------------------------------------ |
 | EPASA              | This is a layer-2 address, fully backwards compatible as Layer-1 address                                      |
-| PASA               | This is the standard layer-1 address of the receiver account                                                  |
+| PASA               | This is the standard layer-1 address of the receiver account (account number or account name)                 |
 | Checksum           | This is the standard layer-1 address checksum                                                                 |
 | ExtendedAddress    | The optional extra text that forms part of layer-2 address (payload specification)                            |
 | PublicPayload      | A payload which is not encrypted and publically visible                                                       |
@@ -64,8 +71,9 @@ An Extended PASA is defined by the below EBNF grammar:
 | SenderEncPayload   | A payload which is ECIES encrypted using the senders public key (only sender can decrypt EPASA)               |
 | PasswordEncPayload | A payload which is AES256 encrypted using the specified password                                              |
 | Payload            | The actual payload data, specified it an well-defined encoding                                                |
-| PayloadChecksum    | An UINT16 specified by two hexbytes (4 hexdigits) that denotes a checksum of payload, used to ensure payload consistency (prevents typo/copy-paste errors)  |
+| PayloadChecksum    | An UINT16 specified by two hexbytes (4 hexnibbles) that denotes a checksum of payload, used to ensure payload consistency (prevents typo/copy-paste errors)  |
 | Password           | The password used in PasswordEndPayload. Must be specified as a SafeAnsiString (chars 32..126)                |
+| Pascal64String     | An ANSI string involving a limited subset used for account names (cannot start with a digit)                  |
 | SafeAnsiString     | An ANSI string involvolving subset characters 32..126                                                         |
 | Base58String       | A Base58-encoded string. This is used for specifying public keys, and hashes of public keys                   |
 | HexString          | A hexadecimal-encoded string prefixed with a 0x. Every byte specified by two hexdigits, lower-case            |
@@ -77,14 +85,22 @@ An Extended PASA is defined by the below EBNF grammar:
 
 #### Validation Rules
 
-#### PASA Checksum
+#### AccountNumber Checksum
 
 Layer-1 account checkum must be the following number:
 
 ```
-  Checksum = ((PASA*101) MOD 89) + 10
+  Checksum = ((AccountNumber*101) MOD 89) + 10
 ```
 
+**NOTE** AccountNumber above denotes the integer portion of the string.
+
+#### Pascal64String 
+
+These strings are used to denote an account names and conform to the following rules.
+- By definition, they must **not** start with a digit. 
+- String length must between 3..64 inclusive.
+
 #### Payload Checksum
 
 In order to avoid data entry errors, the payload portion is **optionally** checksummed. The payload checksum is calculated as follows:
@@ -93,10 +109,10 @@ In order to avoid data entry errors, the payload portion is **optionally** check
     PayloadChecksum = ToHexStringLE ( CastToUINT16( MurMur3( ToAsciiBytes ( PayloadEncType ++ Payload ) ) MOD 65536 ) )
 
     where
-       PayloadEncType  = "0" for PublicPayload
-                       = "1" for ReceiverEncPayload
-                       = "2" for SenderEncPayload
-                       = "3" for PasswordEncPayload
+       PayloadEncType  = "1" for PublicPayload
+                       = "2" for ReceiverEncPayload
+                       = "3" for SenderEncPayload
+                       = "4" for PasswordEncPayload
        ToAsciiBytes    = converts ASCII string argument into raw byte form, character by character (no endianness concerns here)                
        MurMur3         = performs 32bit MurMur3 hash of the byte array argument                
        CastToUINT16    = casts the integer argument into to a 16bit unsigned integer (should never overflow due to modulo 65536)
@@ -123,6 +139,21 @@ The following validation rules must be applied to Payload lengths
  
 ## E-PASA Examples
 
+### Base Cases 
+
+<table>
+<thread>
+    <th width="350">E-PASA</th>
+    <th>Description</th>
+</thead>
+<tbody>
+    <tr><td>123456-77</td><td>Account 123456-77 (backwards compatible with current addresses)</td></tr>
+    <tr><td>pascalcoin-foundation</td><td>Account with name 'pascalcoin-foundation' no payload</td></tr>
+    <tr><td>my-favorite-exchange("[email protected]")</td><td>An account called "my-favorite-exchange" with a recipient-encrypted payload (e.g. an exchange deposit address where only exchange can see payload, used as a user ID)</td></tr>
+</tbody>
+</table>
+
+
 ### With ASCII payloads 
 
 <table>
@@ -188,8 +219,8 @@ The following validation rules must be applied to Payload lengths
     <tr><td>999-72():7ba2</td><td>ECIES encrypted empty payload using <b>recipients</b> public key</td></tr>
     <tr><td>999-72<>:b51f</td><td>ECIES encrypted empty payload using <b>senders</b> public key</td></tr>
     <tr><td>999-72{:Alpha1%}</td><td>AES encrypted empty payload using password <b>Alpha1%</b></td></tr> 
-    <tr><td>999-72{"Hello":Funny\"Pwd}</td><td>AES encrypted empty payload using escaped password <b>Funny"Pwd</b></td></tr> 
-    <tr><td>999-72{"Hello":\\\"\}}</td><td>AES encrypted empty payload using escaped password <b>\"}</b></td></tr>
+    <tr><td>999-72{"Hello":Funny\"Pwd}</td><td>AES encrypted using escaped password <b>Funny"Pwd</b></td></tr> 
+    <tr><td>999-72{"Hello":\\\"\}}</td><td>AES encrypted using escaped password <b>\"}</b></td></tr>
 </tbody>
 </table>