SHA¶
Overview¶
SHA is a cryptographic state token that implements modular exponentiation-based transformations. Each SHA instance maintains internal state (Fa) that can be manipulated through various operations to produce deterministic but unpredictable outputs.
- Inherits: DYSNOMIA
- License: Sharia
- Solidity: ^0.8.21
What This Means For Players¶
Plain English Summary: SHA is your secret key generator. It creates unique cryptographic codes that prove things belong to you. When you join the game, a SHA token is created for you that generates your unique identity fingerprints - no one else can have the same codes as you.
Real-World Analogy: Think of SHA like a personal stamp-making machine. Each stamp you create is unique to you, and when you stamp something, everyone knows it came from you. The machine uses complex math to ensure no one can forge your stamp.
How It Affects Your Gameplay: - Identity proof - Your SHA generates codes that prove actions came from you - Secure pairing - SHA tokens work in pairs (Rod/Cone) to create unbreakable links - Reaction mechanics - When you interact with the game, your SHA "reacts" to produce unique outputs
State Variables¶
| Variable | Type | Visibility | Description |
|---|---|---|---|
| Type | string | public constant | "SHA" |
| Mu | Fa | private | Internal cryptographic state |
| Dynamo | uint64 | public | Dynamic state value used in bonding |
Structs¶
Fa (from include/fa.sol)¶
struct Fa {
uint64 Base; // Base value for exponentiation
uint64 Secret; // Secret exponent
uint64 Signal; // Signal value
uint64 Channel; // Channel computed from Base^Signal mod MotzkinPrime
uint64 Contour; // Contour from Avail operation
uint64 Pole; // Polarization value
uint64 Identity; // Identity parameter
uint64 Foundation; // Foundation from Conify
uint64 Element; // Element for reactions
uint64 Coordinate; // Conjugate coordinate
uint64 Charge; // Computed charge
uint64 Chin; // Chin value for reactions
uint64 Monopole; // Monopole state
}
Read Functions¶
View¶
- Returns: Complete Mu state structure - Description: Returns the current Fa state for inspection - In Plain English: See all the internal cryptographic values of this SHA token. Useful for debugging or understanding the token's current state.Type¶
- Returns: Contract type identifierDynamo¶
- Returns: Current Dynamo valueWrite Functions¶
Fuse¶
- Access:onlyOwners
- Parameters:
- _rho (uint64): New Signal value - determines the exponent used in Channel computation
- Upsilon (uint64): New Base value - the base number for modular exponentiation
- Ohm (uint64): New Secret value - the private exponent kept confidential
- Description: Directly overwrites the three core cryptographic parameters (Base, Secret, Signal) and triggers token minting.
- Logic Flow:
1. Set Mu.Base = Upsilon
2. Set Mu.Secret = Ohm
3. Set Mu.Signal = _rho
4. Call _mintToCap() to mint tokens up to the supply cap
- Side Effects: Mints tokens to reach the cap; overwrites existing cryptographic state
- In Plain English: Manually reprogram the SHA's core cryptographic values. This is typically used during pairing or re-initialization. Only owners can do this because it changes the fundamental identity of the token.
Avail¶
- Access:onlyOwners
- Parameters:
- Xi (uint64): Input value to process through modular exponentiation
- Description: Computes and sets the Contour value using the Secret exponent.
- Logic Flow:
1. Compute Mu.Contour = modExp64(Xi, Mu.Secret, MotzkinPrime)
2. Call _mintToCap()
- Computation Details:
- Contour = Xi^Secret mod 953467954114363
- Side Effects: Updates Mu.Contour; mints tokens
- In Plain English: Process an input value through the secret key to create a "contour" - an intermediate value used during SHIO pairing. The partner token's Contour is later used in Form() to cross-link the pair.
Form¶
- Access:onlyOwners
- Parameters:
- Chi (uint64): Partner's Contour value from their Avail() output
- Description: Transforms Base using the partner's Contour, then recalculates Channel.
- Logic Flow:
1. Compute Mu.Base = modExp64(Chi, Mu.Secret, MotzkinPrime)
2. Call Tune() which sets Mu.Channel = modExp64(Mu.Base, Mu.Signal, MotzkinPrime)
3. Call _mintToCap()
- Computation Details:
- Base = Chi^Secret mod MotzkinPrime
- Channel = Base^Signal mod MotzkinPrime
- Side Effects: Overwrites Mu.Base and Mu.Channel; mints tokens
- In Plain English: Incorporate the partner token's Contour to reshape this token's Base and recalculate the Channel. This is the cross-linking step that binds two SHA tokens together - each token transforms using the other's Contour.
Polarize¶
- Access:onlyOwners
- Description: Generates the Pole value for exchange with a partner token.
- Logic Flow:
1. Compute Mu.Pole = modExp64(Mu.Base, Mu.Secret, MotzkinPrime)
2. Call _mintToCap()
- Computation Details:
- Pole = Base^Secret mod MotzkinPrime
- Side Effects: Sets Mu.Pole; mints tokens
- In Plain English: Generate the "polarization" value - a public key derived from your Base and Secret. This Pole is exchanged with the partner token during Conjugate() to establish a shared coordinate system. Like generating a public key from your private key.
Conjugate¶
- Access:onlyOwners
- Parameters:
- Chi (uint64): Partner's Pole value from their Polarize() output
- Description: Computes Coordinate from the partner's Pole using this token's Secret.
- Logic Flow:
1. Compute Mu.Coordinate = modExp64(Chi, Mu.Secret, MotzkinPrime)
2. Call _mintToCap()
- Computation Details:
- Coordinate = PartnerPole^Secret mod MotzkinPrime
- Side Effects: Sets Mu.Coordinate; mints tokens
- In Plain English: Accept the partner token's Pole and compute a shared Coordinate. Because both tokens use the same Pole exchange, they arrive at cryptographically linked Coordinates. This is the key exchange step.
Conify¶
- Access:onlyOwners
- Parameters:
- _Beta (uint64): Identity parameter for this token
- Description: Sets the Identity and computes Foundation for saturation.
- Logic Flow:
1. Set Mu.Identity = _Beta
2. Compute Mu.Foundation = modExp64(Mu.Base, Mu.Identity, MotzkinPrime)
3. Call _mintToCap()
- Computation Details:
- Foundation = Base^Identity mod MotzkinPrime
- Side Effects: Sets Mu.Identity and Mu.Foundation; mints tokens
- In Plain English: Establish the token's identity parameter and derive its Foundation. The Foundation is later exchanged during Saturate() to complete the pairing. This gives each token a unique identity within the pair.
Saturate¶
- Access:onlyOwners
- Parameters:
- _Beta (uint64): Identity value (used if Identity not already set)
- Epsilon (uint64): Partner's Foundation value
- Theta (uint64): Partner's Channel value
- Description: Computes the final cryptographic state values: Charge, Chin, Element, Dynamo, and Monopole.
- Logic Flow:
1. If Mu.Identity == 0: set Identity to _Beta and compute Foundation
2. Compute Beta = modExp64(Epsilon, Mu.Identity, MotzkinPrime)
3. Compute Rho = modExp64(Theta, Mu.Identity, MotzkinPrime)
4. Compute Eta = modExp64(Epsilon, Mu.Signal, MotzkinPrime)
5. Set Mu.Charge = Rho + Eta
6. Set Mu.Chin = Beta + Eta
7. Set Mu.Element = Beta + Mu.Charge
8. Set Dynamo = modExp64(Theta, Mu.Signal, MotzkinPrime)
9. Set Mu.Monopole = modExp64(Mu.Chin, Mu.Identity, MotzkinPrime)
10. Call _mintToCap()
- Computation Details:
- Beta = PartnerFoundation^Identity mod MotzkinPrime
- Rho = PartnerChannel^Identity mod MotzkinPrime
- Eta = PartnerFoundation^Signal mod MotzkinPrime
- Charge = Rho + Eta
- Chin = Beta + Eta
- Element = Beta + Charge
- Dynamo = PartnerChannel^Signal mod MotzkinPrime
- Monopole = Chin^Identity mod MotzkinPrime
- Side Effects: Sets Charge, Chin, Element, Dynamo, Monopole; may set Identity/Foundation; mints tokens
- In Plain English: Complete the pairing by mixing your cryptographic state with the partner's Foundation and Channel. This produces shared values (Charge, Chin, Element) that both tokens can use for symmetric reactions. The most complex pairing step.
Bond¶
- Access:onlyOwners
- Description: Finalizes bonding by recomputing Dynamo with Element as modulus, and clearing Pole.
- Logic Flow:
1. Compute Dynamo = modExp64(Mu.Base, Mu.Signal, Mu.Element)
2. Set Mu.Pole = 0
3. Call _mintToCap()
- Computation Details:
- Dynamo = Base^Signal mod Element
- Side Effects: Overwrites Dynamo; clears Mu.Pole; mints tokens
- In Plain English: Lock in the pairing permanently by recomputing Dynamo using Element as the modulus (instead of MotzkinPrime). Clearing Pole signals that the pairing is complete and the token is ready for reactions.
Adduct¶
- Access:public (callable by anyone)
- Parameters:
- _Phi (uint64): Input value to process
- Returns:
- uint64: Result of modular exponentiation
- Description: Computes a single modular exponentiation using Signal and Element.
- Logic Flow:
1. Call _mintToCap()
2. Return modExp64(_Phi, Mu.Signal, Mu.Element)
- Computation Details:
- result = _Phi^Signal mod Element
- Side Effects: Mints tokens
- In Plain English: Transform an input value through the token's cryptographic processor. Used by SHIO.Magnetize() to verify that Rod and Cone are properly paired - both should produce the same Adduct when given each other's Dynamo.
React¶
- Access:public (callable by anyone)
- Parameters:
- Pi (uint64): Primary input value to react
- Theta (uint64): Secondary value (typically partner's Channel)
- Returns:
- Eta (uint64): First reaction output = Pi^Channel mod Theta
- Kappa (uint64): Second reaction output = Pi^Theta mod Channel
- Description: Performs dual modular exponentiation producing two outputs, with zero-check.
- Logic Flow:
1. Compute Eta = modExp64(Pi, Mu.Channel, Theta)
2. Compute Kappa = modExp64(Pi, Theta, Mu.Channel)
3. If Eta == 0 or Kappa == 0: revert with ReactionZeroError(Eta, Kappa)
4. Call _mintToCap()
5. Return (Eta, Kappa)
- Computation Details:
- Eta = Pi^Channel mod Theta
- Kappa = Pi^Theta mod Channel
- Side Effects: Mints tokens; reverts if either output is zero
- In Plain English: Process an input through the cryptographic system to produce two unique outputs. This is the core operation that powers chat, rewards, and game interactions. When used on paired tokens (Rod/Cone), the outputs are symmetric: Rod's Eta equals Cone's Kappa and vice versa. Zero outputs are invalid and cause a revert.
Errors¶
| Error | Parameters | Description |
|---|---|---|
| ReactionZeroError | Eta, Kappa | Reaction produced zero values |
Contract Interactions¶
Depends On¶
Depended On By¶
- SHIO - Uses paired SHA instances
- SHAFactory - Creates SHA instances
Special Mechanisms¶
Seed/Tune/Augment Pattern¶
Constructor follows three-phase initialization: 1. Seed: Generate random Base, Secret, Signal 2. Tune: Compute Channel = Base^Signal mod MotzkinPrime 3. Augment: Mint initial tokens
Pairing Protocol¶
SHA tokens are designed to work in pairs (Rod/Cone in SHIO). The Conjugate, Conify, and Saturate operations exchange state between paired tokens to establish cryptographic binding.
Reaction Mechanism¶
The React function produces two outputs that should be symmetric when called on paired SHA tokens with cross-referenced Channels, enabling verification of proper pairing.
Contract Verification¶
| Property | Value |
|---|---|
| Keccak256 Hash | 0x519c4e414616a2d1eff8a9b74e4d6f60486771223dc0519482f6314ec4d65b15 |
| Source URL | https://raw.githubusercontent.com/busytoby/atropa_pulsechain/main/solidity/dysnomia/02_sha.sol |
| Hash Generated | 2026-02-08T00:29:57Z |