Skip to main content

Module sui::nitro_attestation

use std::ascii;
use std::bcs;
use std::option;
use std::string;
use std::vector;
use sui::address;
use sui::clock;
use sui::hex;
use sui::object;
use sui::transfer;
use sui::tx_context;

Struct PCREntry

Represents a PCR entry with an index and value.

public struct PCREntry has drop
Click to open
Fields
index: u8
value: vector<u8>

Struct NitroAttestationDocument

Nitro Attestation Document defined for AWS.

public struct NitroAttestationDocument has drop
Click to open
Fields
module_id: vector<u8>
Issuing Nitro hypervisor module ID.
timestamp: u64
UTC time when document was created, in milliseconds since UNIX epoch.
digest: vector<u8>
The digest function used for calculating the register values.
pcrs: vector<sui::nitro_attestation::PCREntry>
A list of PCREntry containing the index and the PCR bytes. .
public_key: std::option::Option<vector<u8>>
An optional DER-encoded key the attestation, consumer can use to encrypt data with.
user_data: std::option::Option<vector<u8>>
Additional signed user data, defined by protocol.
nonce: std::option::Option<vector<u8>>
An optional cryptographic nonce provided by the attestation consumer as a proof of authenticity.

Constants

Error that the PCRs are invalid.

const EInvalidPCRsError: u64 = 3;

Error that the feature is not available on this network.

const ENotSupportedError: u64 = 0;

Error that the attestation input failed to be parsed.

const EParseError: u64 = 1;

Error that the attestation failed to be verified.

const EVerifyError: u64 = 2;

Function load_nitro_attestation

@param attestation: attesttaion documents bytes data. @param clock: the clock object.

Returns the parsed NitroAttestationDocument after verifying the attestation, may abort with errors described above.

entry fun load_nitro_attestation(attestation: vector<u8>, clock: &sui::clock::Clock): sui::nitro_attestation::NitroAttestationDocument
Click to open
Implementation
entry fun load_nitro_attestation(
    attestation: vector<u8>,
    clock: &Clock
): NitroAttestationDocument {
    load_nitro_attestation_internal(&attestation, clock::timestamp_ms(clock))
}

Function module_id

public fun module_id(attestation: &sui::nitro_attestation::NitroAttestationDocument): &vector<u8>
Click to open
Implementation
public fun module_id(attestation: &NitroAttestationDocument): &vector<u8> {
    &attestation.module_id
}

Function timestamp

public fun timestamp(attestation: &sui::nitro_attestation::NitroAttestationDocument): &u64
Click to open
Implementation
public fun timestamp(attestation: &NitroAttestationDocument): &u64 {
    &attestation.timestamp
}

Function digest

public fun digest(attestation: &sui::nitro_attestation::NitroAttestationDocument): &vector<u8>
Click to open
Implementation
public fun digest(attestation: &NitroAttestationDocument): &vector<u8> {
    &attestation.digest
}

Function pcrs

Returns a list of mapping PCREntry containg the index and the PCR bytes. Currently AWS supports PCR0, PCR1, PCR2, PCR3, PCR4, PCR8.

public fun pcrs(attestation: &sui::nitro_attestation::NitroAttestationDocument): &vector<sui::nitro_attestation::PCREntry>
Click to open
Implementation
public fun pcrs(attestation: &NitroAttestationDocument): &vector<PCREntry> {
    &attestation.pcrs
}

Function public_key

public fun public_key(attestation: &sui::nitro_attestation::NitroAttestationDocument): &std::option::Option<vector<u8>>
Click to open
Implementation
public fun public_key(attestation: &NitroAttestationDocument): &Option<vector<u8>> {
    &attestation.public_key
}

Function user_data

public fun user_data(attestation: &sui::nitro_attestation::NitroAttestationDocument): &std::option::Option<vector<u8>>
Click to open
Implementation
public fun user_data(attestation: &NitroAttestationDocument): &Option<vector<u8>> {
    &attestation.user_data
}

Function nonce

public fun nonce(attestation: &sui::nitro_attestation::NitroAttestationDocument): &std::option::Option<vector<u8>>
Click to open
Implementation
public fun nonce(attestation: &NitroAttestationDocument): &Option<vector<u8>> {
    &attestation.nonce
}

Function index

public fun index(entry: &sui::nitro_attestation::PCREntry): u8
Click to open
Implementation
public fun index(entry: &PCREntry): u8 {
    entry.index
}

Function value

public fun value(entry: &sui::nitro_attestation::PCREntry): &vector<u8>
Click to open
Implementation
public fun value(entry: &PCREntry): &vector<u8> {
    &entry.value
}

Function load_nitro_attestation_internal

Internal native function

fun load_nitro_attestation_internal(attestation: &vector<u8>, current_timestamp: u64): sui::nitro_attestation::NitroAttestationDocument
Click to open
Implementation
native fun load_nitro_attestation_internal(
    attestation: &vector<u8>,
    current_timestamp: u64,
): NitroAttestationDocument;