HashAlgorithm
From Erights
m (formatting) |
Kevin Reid (Talk | contribs) (idea related to Hash upgradability) |
||
Line 12: | Line 12: | ||
Returns the number of bits in the hashes produced. | Returns the number of bits in the hashes produced. | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
===Extensions=== | ===Extensions=== | ||
Line 27: | Line 17: | ||
To discuss: add convenience method to hash a given List[0..255]? A given integer? | To discuss: add convenience method to hash a given List[0..255]? A given integer? | ||
- | ==Hash | + | ==Hash== |
- | For flexibility, discoverability, and type checking benefits, hash algorithms return Hash objects which contain the bits of the hash value. All hash algorithms | + | For flexibility, discoverability, and type checking benefits, hash algorithms return Hash objects which contain the bits of the hash value. All hash algorithms produce the same Hash object, but Hash objects are tagged with the algorithm that produced them. |
- | Hash objects are | + | Hash objects are Selfless. Their portrayal is <code>[makeHash, "run", [<var>hashAlgorithm</var>, <var>hashBits</var> :[[List]][0..255]]]</code>. |
- | + | {{XXX|What exactly is the hashAlgorithm value of a Hash? The algorithm object? A string? Must take into consideration letting them unserialize on vats that don't have the hash algorithm itself.}} | |
- | + | ||
- | + | ||
- | {{instance msgdoc| | + | {{instance msgdoc|integer|0||[[Integer]]}} |
- | Returns the hash value as a | + | Returns the hash value interpreted as a big-endian unsigned integer. |
- | {{instance msgdoc| | + | {{instance msgdoc|octets|0||[[List]][0..255]}} |
- | + | ||
- | + | ||
- | + | Returns the hash value as a list of octets. | |
- | + | {{instance msgdoc|op__cmp|1|other :any[Hash, any]|comparison result}} {{XXX write spec on op__cmp and how this should be described}} | |
- | + | The comparison protocol. If the hash algorithm is the same, a lexicographic comparison of the bits, else incomparable (NaN). | |
- | + | {{XXX|add method to expose hashAlgorithm}} |
Revision as of 00:03, 30 August 2009
Part of a Hash upgradability design issue proposal.
Please comment, especially on whether this seems overly baroque. --Kevin Reid 19:03, 29 August 2009 (CDT)
Contents |
HashAlgorithm object protocol
run/0
Prepares for a hash computation. Write the data to be hashed to the returned OutStream; when it is closed the returned promise will (synchronously) resolve to the hash value.
hashSize/0
- Signature: hashSize() :Integer
Returns the number of bits in the hashes produced.
Extensions
To discuss: add convenience method to hash a given List[0..255]? A given integer?
Hash
For flexibility, discoverability, and type checking benefits, hash algorithms return Hash objects which contain the bits of the hash value. All hash algorithms produce the same Hash object, but Hash objects are tagged with the algorithm that produced them.
Hash objects are Selfless. Their portrayal is [makeHash, "run", [hashAlgorithm, hashBits :List[0..255]]]
.
XXX What exactly is the hashAlgorithm value of a Hash? The algorithm object? A string? Must take into consideration letting them unserialize on vats that don't have the hash algorithm itself.
integer/0
- Signature: integer() :Integer
Returns the hash value interpreted as a big-endian unsigned integer.
octets/0
- Signature: octets() :List[0..255]
Returns the hash value as a list of octets.
op__cmp/1
- Signature: op__cmp(other :any[Hash, any]) :comparison result Template:XXX write spec on op cmp and how this should be described
The comparison protocol. If the hash algorithm is the same, a lexicographic comparison of the bits, else incomparable (NaN).
XXX add method to expose hashAlgorithm