Aleo Oracle JavaScript SDK 的简单使用

Aleo Oracle SDK for JavaScript 是一个 Node.js 包。

这个 SDK 不使用默认导出。

在内部,这个 API 使用 Fetch API。只要你提供 Fetch API 的实现,它可能在任何 JS 环境中使用。

由于客户端允许配置自定义的公证和验证后端,它还允许提供 Fetch 选项的覆盖,用于与这些后端通信 - 详见 OracleClient 构造函数。

目录

  • 安装

  • 常量:

    • DEFAULT_FETCH_OPTIONS

    • DEFAULT_NOTARIZATION_BACKENDS

    • DEFAULT_NOTARIZATION_HEADERS

    • DEFAULT_NOTARIZATION_OPTIONS

    • DEFAULT_VERIFICATION_BACKEND

  • 类型:

    • class AttestationError

    • class AttestationIntegrityError

    • class DebugAttestationError

    • class OracleClient

      • constructor

      • notarize

      • testSelector

      • enclavesInfo

    • 类型 AttestationRequest

    • 类型 AttestationResponse

    • 类型 ClientConfig

    • 类型 CustomBackendAllowedFetchOptions

    • 类型 CustomBackendConfig

    • 类型 DebugRequestResponse

    • 类型 EnclaveInfo

    • 类型 EncodingOptions

    • 类型 InfoOptions

    • 类型 NotarizationOptions

    • 类型 OracleData

    • 类型 PositionInfo

    • 类型 ProofPositionalInfo

    • 类型 SgxInfo

安装

通过运行 npm install @zkportal/aleo-oracle-sdk 安装 SDK。

常量

DEFAULT_FETCH_OPTIONS

默认的 Fetch API 选项,应用于所有发往公证和验证后端的请求。

{
  cache: 'no-store',
  mode: 'cors',
  redirect: 'follow',
  referrer: '',
  keepalive: false,
}

DEFAULT_NOTARIZATION_BACKENDS

如果没有向客户端提供 notarizer 配置,将使用的公证后端配置列表。

类型:[CustomBackendConfig[]](#类型 custombackendconfig)。

[
  {
    address: 'sgx.aleooracle.xyz',
    port: 443,
    https: true,
    apiPrefix: '',
    resolve: true,
    init: DEFAULT_FETCH_OPTIONS,
  },
]

DEFAULT_NOTARIZATION_HEADERS

添加到所有发往证明目标的请求的默认 HTTP 请求头。

{
  'Accept': '*/*',
  'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36',
  'Upgrade-Insecure-Requests': '1',
  'DNT': '1',
}

DEFAULT_NOTARIZATION_OPTIONS

类型:[NotarizationOptions](#类型 notarizationoptions)

{
  dataShouldMatch: true,
  timeout: 5000,
  maxTimeDeviation: undefined,
}

DEFAULT_VERIFICATION_BACKEND

如果没有向客户端提供 verifier 配置,将使用的公证后端配置列表。

类型:[CustomBackendConfig](#类型 custombackendconfig)。

{
  address: 'verifier.aleooracle.xyz',
  port: 443,
  https: true,
  apiPrefix: '',
  resolve: true,
  init: DEFAULT_FETCH_OPTIONS,
}

类型

class AttestationError

扩展自:Error

class AttestationIntegrityError

扩展自:Error

class DebugAttestationError

扩展自:Error

Alt Text
Alt Text

class OracleClient

constructor

Alt Text
Alt Text

notarize

Alt Text
Alt Text
Alt Text
Alt Text
Alt Text
Alt Text

testSelector

Alt Text
Alt Text

enclavesInfo

Alt Text
Alt Text

类型 AttestationRequest

对 HTTPS 资源的公证和证明请求,并使用数据选择器从响应中提取证明数据。还描述了预期的响应格式,以及如何为 Aleo 程序编码提取的证明数据。

Alt Text
Alt Text

类型 AttestationResponse

公证后端对证明请求的响应。

Alt Text
Alt Text

类型 ClientConfig

Oracle 客户端配置对象。

Alt Text
Alt Text

类型 CustomBackendAllowedFetchOptions

Omit<RequestInit, 'body' | 'integrity' | 'method'>

类型 CustomBackendConfig

Oracle 客户端将用于公证/验证的后端配置。

Alt Text
Alt Text

类型 DebugRequestResponse

用于调试选择器的公证响应。

Alt Text
Alt Text

类型 EnclaveInfo

关于公证后端运行的 TEE 的信息。

Alt Text
Alt Text

类型 EncodingOptions

描述解释提取的证明数据以编码为 Aleo 程序兼容格式的方法。

参见 Aleo 编码指南

Alt Text
Alt Text

类型 InfoOptions

获取安全区信息请求的选项。

Alt Text
Alt Text

类型 NotarizationOptions

公证客户端选项。参见 公证和证明指南

Alt Text
Alt Text

类型 OracleData

直接用于 Aleo 程序中的证明相关信息。参见 Aleo 编码指南编码文档 以了解这些值的创建方式。

Alt Text
Alt Text

类型 PositionInfo

描述编码为 Aleo 程序格式的属性的位置和长度。

Alt Text
Alt Text

类型 ProofPositionalInfo

关于 Aleo 编码的证明响应中不同属性位置的信息。计数在 Aleo 的 u128 属性上进行,计数从 0 开始。

位置不考虑嵌套结构,并且可能会超出 Aleo 允许的类型属性数量限制。

请参阅编码文档。

Alt Text
Alt Text

类型 SgxInfo

关于运行公证后端的 Intel SGX 安全区的信息。包括一些为了方便在 Aleo 程序中使用而编码的额外属性。

Alt Text
Alt Text

Aleo 官方链接:

Subscribe to Yaakov
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.