Expand description
Content-addressing for the flat personality.
§This is not a cryptographic hash
It is FNV-1a run four times under different seeds and concatenated.
FNV is trivially collidable by construction — anyone who can choose
two inputs can make them collide. A personality that accepts objects
from an untrusted party must use a real cryptographic hash
(JAVM uses BLAKE2 through javm-cap); using this one there would let
an attacker substitute one program for another.
It is here because the flat personality’s job is to be the smallest
complete example of the Personality/GuestPersonality pair, and to
make nub’s own benchmarks runnable. In that setting there is no
adversary, and a dependency-free 40-line hash keeps the example
readable and keeps the guest build free of a crate that would want
CPU feature detection on x86_64-unknown-none.
The one real constraint it must satisfy: host and guest compute the same value, since the host publishes by hash and invokes by hash. That is what the round-trip test pins.
Constants§
- ERROR_
SENTINEL - The wire’s put-failure sentinel.
GuestStore::put_objectmust never return this value for a real object; with four independent 64-bit lanes the odds of hitting all-ones are nil, butcontent_hashforces a bit clear rather than relying on that.
Functions§
- content_
hash - Content-address
bytes.
Type Aliases§
- Hash
- 32-byte object identity, matching
nub_kernel::ObjHash’s shape.