import * as _chainsafe_ssz from '@chainsafe/ssz';
import { ByteVectorType, UintBigintType, ContainerType, ByteListType, ListCompositeType, UintNumberType } from '@chainsafe/ssz';

/**
 * Primitive SSZ schemas and constants used across AsentumChain's type system.
 *
 * These are the low-level building blocks: byte vectors for addresses and
 * hashes, bigint types for balances and nonces, and canonical sizes for
 * Dilithium3 keys and signatures.
 */

/** Length of an AsentumChain address in bytes. */
declare const ADDRESS_BYTES = 20;
/** Length of a chain hash (BLAKE3 output) in bytes. */
declare const HASH_BYTES = 32;
/** Exact size of a Dilithium3 (ML-DSA-65) public key in bytes, per NIST FIPS 204. */
declare const DILITHIUM3_PUBLIC_KEY_BYTES = 1952;
/** Exact size of a Dilithium3 (ML-DSA-65) signature in bytes, per NIST FIPS 204. */
declare const DILITHIUM3_SIGNATURE_BYTES = 3309;
/** The zero address (20 zero bytes). Used for contract creation and null-sender sentinel. */
declare const ZERO_ADDRESS_BYTES: Uint8Array;
/** The zero hash (32 zero bytes). Used as a sentinel for EOA code hash and storage root. */
declare const ZERO_HASH: Uint8Array;
/** SSZ schema for a 20-byte address. */
declare const AddressBytesSchema: ByteVectorType;
/** SSZ schema for a 32-byte chain hash. */
declare const HashSchema: ByteVectorType;
/** SSZ schema for a 256-bit unsigned integer (represented as bigint at runtime). */
declare const Uint256Schema: UintBigintType;
/** SSZ schema for a 64-bit unsigned integer (represented as bigint at runtime). */
declare const Uint64Schema: UintBigintType;

/** SSZ schema for an AsentumChain account. */
declare const AccountSchema: ContainerType<{
    balance: _chainsafe_ssz.UintBigintType;
    nonce: _chainsafe_ssz.UintBigintType;
    codeHash: _chainsafe_ssz.ByteVectorType;
    storageRoot: _chainsafe_ssz.ByteVectorType;
}>;
/** An AsentumChain account at rest (the value stored against an address in state). */
interface Account {
    balance: bigint;
    nonce: bigint;
    codeHash: Uint8Array;
    storageRoot: Uint8Array;
}
/**
 * Returns a fresh, empty externally-owned account: zero balance, zero nonce,
 * zero code hash, zero storage root. Used as the default for addresses that
 * have never been touched.
 */
declare function emptyAccount(): Account;

/**
 * The body of a transaction — the portion that gets hashed and signed.
 *
 * A receiver `to` value of 20 zero bytes indicates a contract creation.
 */
declare const TransactionBodySchema: ContainerType<{
    chainId: _chainsafe_ssz.UintBigintType;
    nonce: _chainsafe_ssz.UintBigintType;
    maxPriorityFeePerGas: _chainsafe_ssz.UintBigintType;
    maxFeePerGas: _chainsafe_ssz.UintBigintType;
    gasLimit: _chainsafe_ssz.UintBigintType;
    to: ByteVectorType;
    value: _chainsafe_ssz.UintBigintType;
    data: ByteListType;
}>;
/** Runtime shape of a transaction body. */
interface TransactionBody {
    chainId: bigint;
    nonce: bigint;
    maxPriorityFeePerGas: bigint;
    maxFeePerGas: bigint;
    gasLimit: bigint;
    to: Uint8Array;
    value: bigint;
    data: Uint8Array;
}
/**
 * A fully signed transaction: a body plus the sender's Dilithium3 public key
 * and signature.
 *
 * The sender address is derivable from `publicKey` (per D16), so we don't
 * store it redundantly. Future optimization: allow the public key to be
 * replaced by an already-known account reference, per the "repeat sender"
 * optimization in `post-quantum.md`.
 */
declare const SignedTransactionSchema: ContainerType<{
    body: ContainerType<{
        chainId: _chainsafe_ssz.UintBigintType;
        nonce: _chainsafe_ssz.UintBigintType;
        maxPriorityFeePerGas: _chainsafe_ssz.UintBigintType;
        maxFeePerGas: _chainsafe_ssz.UintBigintType;
        gasLimit: _chainsafe_ssz.UintBigintType;
        to: ByteVectorType;
        value: _chainsafe_ssz.UintBigintType;
        data: ByteListType;
    }>;
    publicKey: ByteVectorType;
    signature: ByteVectorType;
}>;
/** Runtime shape of a signed transaction. */
interface SignedTransaction {
    body: TransactionBody;
    publicKey: Uint8Array;
    signature: Uint8Array;
}

/** Maximum number of transactions per block. */
declare const MAX_TRANSACTIONS_PER_BLOCK = 10000;
/**
 * Maximum committee size we can encode in the lastCommit bitmap.
 * 16 bytes × 8 bits/byte = 128 slots — comfortably above the 100-validator
 * committee cap, leaves headroom if the cap is raised in v2.
 */
declare const LAST_COMMIT_BITMAP_BYTES = 16;
declare const LAST_COMMIT_BITMAP_SLOTS: number;
/** Fixed-size byte vector for the last-commit bitmap. */
declare const LastCommitBitmapSchema: ByteVectorType;
/** SSZ schema for a block header. */
declare const BlockHeaderSchema: ContainerType<{
    parentHash: ByteVectorType;
    stateRoot: ByteVectorType;
    transactionsRoot: ByteVectorType;
    receiptsRoot: ByteVectorType;
    number: _chainsafe_ssz.UintBigintType;
    timestamp: _chainsafe_ssz.UintBigintType;
    gasLimit: _chainsafe_ssz.UintBigintType;
    gasUsed: _chainsafe_ssz.UintBigintType;
    baseFeePerGas: _chainsafe_ssz.UintBigintType;
    proposer: ByteVectorType;
    /**
     * Bitmap of which validators in the PRIOR block's committee precommitted
     * the prior block. Bit `i` is 1 iff committee[i] (in deterministic order)
     * had a precommit observed by this block's producer. Used by the rewards
     * distributor to credit only validators who actually signed — the
     * "auto-liveness" mechanism. Empty (all-zero) for block 1, since there
     * is no prior block.
     */
    lastCommitBitmap: ByteVectorType;
}>;
/** Runtime shape of a block header. */
interface BlockHeader {
    parentHash: Uint8Array;
    stateRoot: Uint8Array;
    transactionsRoot: Uint8Array;
    receiptsRoot: Uint8Array;
    number: bigint;
    timestamp: bigint;
    gasLimit: bigint;
    gasUsed: bigint;
    baseFeePerGas: bigint;
    proposer: Uint8Array;
    lastCommitBitmap: Uint8Array;
}
/** SSZ schema for a full block. */
declare const BlockSchema: ContainerType<{
    header: ContainerType<{
        parentHash: ByteVectorType;
        stateRoot: ByteVectorType;
        transactionsRoot: ByteVectorType;
        receiptsRoot: ByteVectorType;
        number: _chainsafe_ssz.UintBigintType;
        timestamp: _chainsafe_ssz.UintBigintType;
        gasLimit: _chainsafe_ssz.UintBigintType;
        gasUsed: _chainsafe_ssz.UintBigintType;
        baseFeePerGas: _chainsafe_ssz.UintBigintType;
        proposer: ByteVectorType;
        /**
         * Bitmap of which validators in the PRIOR block's committee precommitted
         * the prior block. Bit `i` is 1 iff committee[i] (in deterministic order)
         * had a precommit observed by this block's producer. Used by the rewards
         * distributor to credit only validators who actually signed — the
         * "auto-liveness" mechanism. Empty (all-zero) for block 1, since there
         * is no prior block.
         */
        lastCommitBitmap: ByteVectorType;
    }>;
    transactions: ListCompositeType<ContainerType<{
        body: ContainerType<{
            chainId: _chainsafe_ssz.UintBigintType;
            nonce: _chainsafe_ssz.UintBigintType;
            maxPriorityFeePerGas: _chainsafe_ssz.UintBigintType;
            maxFeePerGas: _chainsafe_ssz.UintBigintType;
            gasLimit: _chainsafe_ssz.UintBigintType;
            to: ByteVectorType;
            value: _chainsafe_ssz.UintBigintType;
            data: _chainsafe_ssz.ByteListType;
        }>;
        publicKey: ByteVectorType;
        signature: ByteVectorType;
    }>>;
}>;
/** Runtime shape of a full block. */
interface Block {
    header: BlockHeader;
    transactions: SignedTransaction[];
}

/**
 * An empty transaction body with zero values everywhere. Useful for tests
 * and for building up transactions field-by-field.
 */
declare function emptyTransactionBody(): TransactionBody;
/**
 * An empty block header with zero values everywhere. Useful for constructing
 * a genesis block or for tests that only care about a subset of fields.
 */
declare function emptyBlockHeader(): BlockHeader;

/** Vote kind discriminator — PreVote (0) or PreCommit (1). */
declare const VOTE_KIND_PREVOTE = 0;
declare const VOTE_KIND_PRECOMMIT = 1;
/**
 * SSZ schema for the signed portion of a vote — the canonical bytes
 * that get hashed and signed.
 */
declare const VoteBodySchema: ContainerType<{
    /** 0 = PreVote, 1 = PreCommit. uint8 so a single byte differentiates the two phases. */
    kind: UintNumberType;
    /** Chain ID, to prevent cross-chain vote replay. */
    chainId: _chainsafe_ssz.UintBigintType;
    /** Block number being voted on. */
    height: _chainsafe_ssz.UintBigintType;
    /** Consensus round within the height — increments on timeout or nil-block. */
    round: _chainsafe_ssz.UintBigintType;
    /**
     * Hash of the proposed block header. 32 bytes of zero is a "nil" vote,
     * meaning "I'm voting to advance the round without committing any block".
     */
    blockHash: ByteVectorType;
    /** Validator's 20-byte address, derivable from their public key. */
    validator: ByteVectorType;
}>;
/** Runtime shape of the signed portion of a vote. */
interface VoteBody {
    kind: number;
    chainId: bigint;
    height: bigint;
    round: bigint;
    blockHash: Uint8Array;
    validator: Uint8Array;
}
/** SSZ schema for a signed vote — body plus the validator's Dilithium3 key and signature. */
declare const SignedVoteSchema: ContainerType<{
    body: ContainerType<{
        /** 0 = PreVote, 1 = PreCommit. uint8 so a single byte differentiates the two phases. */
        kind: UintNumberType;
        /** Chain ID, to prevent cross-chain vote replay. */
        chainId: _chainsafe_ssz.UintBigintType;
        /** Block number being voted on. */
        height: _chainsafe_ssz.UintBigintType;
        /** Consensus round within the height — increments on timeout or nil-block. */
        round: _chainsafe_ssz.UintBigintType;
        /**
         * Hash of the proposed block header. 32 bytes of zero is a "nil" vote,
         * meaning "I'm voting to advance the round without committing any block".
         */
        blockHash: ByteVectorType;
        /** Validator's 20-byte address, derivable from their public key. */
        validator: ByteVectorType;
    }>;
    publicKey: ByteVectorType;
    signature: ByteVectorType;
}>;
/** Runtime shape of a signed vote. */
interface SignedVote {
    body: VoteBody;
    publicKey: Uint8Array;
    signature: Uint8Array;
}

export { ADDRESS_BYTES, type Account, AccountSchema, AddressBytesSchema, type Block, type BlockHeader, BlockHeaderSchema, BlockSchema, DILITHIUM3_PUBLIC_KEY_BYTES, DILITHIUM3_SIGNATURE_BYTES, HASH_BYTES, HashSchema, LAST_COMMIT_BITMAP_BYTES, LAST_COMMIT_BITMAP_SLOTS, LastCommitBitmapSchema, MAX_TRANSACTIONS_PER_BLOCK, type SignedTransaction, SignedTransactionSchema, type SignedVote, SignedVoteSchema, type TransactionBody, TransactionBodySchema, Uint256Schema, Uint64Schema, VOTE_KIND_PRECOMMIT, VOTE_KIND_PREVOTE, type VoteBody, VoteBodySchema, ZERO_ADDRESS_BYTES, ZERO_HASH, emptyAccount, emptyBlockHeader, emptyTransactionBody };
