silk/insecure_seed
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc.
One provider-stable 128-bit value for initialization-time hash-flood hardening.
When to use
Read InsecureSeed once while initializing a language runtime or application data structure.
Use fixed in deterministic environments or fromRandom when secure randomness is present.
Details
A provider returns the same copyable Seed on every shared read. fromRandom consumes two
secure words exactly once and stores them in an immutable provider.
Gotchas
This capability is not a reusable stream and makes no cryptographic promise. Current Silk hash collections use a different one-word hash policy and do not consume this seed automatically.
Examples
Provide a deterministic initialization seed
import silk.effect { Effect }
import silk.insecure_seed { InsecureSeed }
pub fn main() -> i32 {
let provider = InsecureSeed.fixed(20, 22)
let seed = run InsecureSeed.get()
|> Effect.provide<InsecureSeed>(&provider)
if InsecureSeed.first(&seed) + InsecureSeed.second(&seed) != 42 { return 0 }
return 42
}Import as InsecureSeed with import silk.insecure_seed { InsecureSeed }.
Public declarations: 3.
Seed
pub struct SeedA copyable pair of initialization seed words with private representation.
Implementation Copy for Seed
impl Copy for SeedInsecureSeed
pub service InsecureSeedA shared capability that returns one provider-stable Seed.
Operation get
effect<'static> fn get() -> Seed ? &InsecureSeedReturns a copy of the provider's stable seed.
Associated function InsecureSeed.first
pub fn first<'life0>(seed: &'life0 silk/insecure_seed.Seed) -> u64Returns the first word of seed.
Associated function InsecureSeed.second
pub fn second<'life0>(seed: &'life0 silk/insecure_seed.Seed) -> u64Returns the second word of seed.
Associated function InsecureSeed.fixed
pub fn fixed(first: u64, second: u64) -> FixedInsecureSeedCreates a deterministic provider from two explicit words without requiring secure randomness.
Associated function InsecureSeed.fromRandom
pub effect<'static> fn fromRandom() -> FixedInsecureSeed ? &mut RandomSamples two secure words once and returns an immutable seed provider.
FixedInsecureSeed
pub struct FixedInsecureSeedAn immutable provider containing one fixed seed.
Implementation InsecureSeed for FixedInsecureSeed
impl InsecureSeed for FixedInsecureSeedOperation get
get = FixedInsecureSeed.fixedGet