Ontology Developer Center
DISCOVERCOMMUNITYSUPPORT
  • Introduction
  • Discover Ontology
  • Getting Started
  • Glossary
  • Decentralized Identity and Data
    • ONT ID
      • Decentralized Identifiers
        • Method Specification for Ontology
        • Method Specification for Ethereum
        • Method Specification for BSC
      • Verifiable Credentials
        • Anonymous Credentials
      • ONT Login
        • Scenarios
        • Protocol Specification
        • Front-end JavaScript SDK
          • Integration and Usage
          • API Reference
        • Front-end UI SDK
          • Integration and Usage
          • API Reference
        • Back-end Go SDK
          • Integration and Usage
          • API Reference
        • Back-end Java SDK
          • Integration and Usage
          • API Reference
      • ONT TAG
        • Workflow
        • API Reference
      • Mercury
      • OScore
    • DDXF
      • Components and Interfaces
      • GREP
      • Overall Scheme
      • Solutions
        • Marketplace
          • Deployment
          • Scenarios
          • SaaS Tenant
          • Java SDK
        • Data Storage
          • Deployment
          • Java SDK
        • Resource Auditor
        • Offline Judge
      • Use Cases
        • E-Shops
  • ONTOLOGY ELEMENTS
    • Smart Contracts
      • Types of smart contracts
    • Token Protocols
    • Consensus Mechanism
    • Ontology Oracle
      • Oracle Process Flow
  • GUIDES & TUTORIALS
    • Development Guides
      • dApp Development
        • Using the dAPI
        • Data Synchronization
      • Smart Contract Development
        • EVM Contract
          • Development Environment and Tools
          • Wallet Setup
          • Contract Development
          • How to Deploy a Smart Contract with GetBlock
        • NeoVM Contract
          • Development tools and environment
          • Launching the IDE
          • Writing and editing program logic
          • Deploying and testing on private net
        • WASM Contract
          • Development Environment
          • Project Initiation - Hello World
          • Creating your own project
          • Development using SmartX
          • Runtime API
          • Contract Fundamentals
          • Inter-contract Interaction
          • Developing Contracts in C++
        • Publish Contract Source Code
    • Integration Guides
      • dApp Integration
        • dAPI Integration
          • Chrome Plugin
          • Mobile wallet dApp
          • QR code mechanism
          • Wake call mechanism
        • Cocos 2D-x
        • Unity 3D applications
      • Mobile Wallet Integration
        • SDK integration
        • dAPI Integration
          • In-wallet applications
          • QR code mechanism
          • Wake call mechanism
        • Stake
      • Using ONT ID
      • Exchange Integration
        • Exchange Docking Guide
        • Exchange API
      • Ontology for dApp Stores
    • EVM & Token Decimals Upgrade
  • ONTOLOGY NODE
    • Abstract
    • Node Deployment
      • Standard Node
      • Rosetta Node
    • Interacting with a Public Node
  • DEVELOPER TOOLS
    • dApp Development Framework
      • Punica CLI
      • Punica boxes
      • Solo Chain
    • IDE
    • APIs
      • HTTP API
        • Restful
        • WebSocket
        • Remote Procedure Call (RPC)
      • Explorer v2 API
        • Block
        • Address
        • Contract
        • Token
        • Transactions
        • ONT ID
        • Summary
        • Node
      • Native Token API
        • ONT Contract API
        • ONG Contract API
      • ONT ID Contract API
      • Web3 API
      • OScore Open API
      • Rosetta Node API
        • Data API
        • Construction API
      • DToken Contract API
      • DDXF
        • Marketplace Contract API
        • Storage API
      • Governance API
    • Digital Wallet
      • Chrome Plugin provider
      • Chrome Plugin dAPI
      • Mobile version provider
      • Mobile version dAPI
    • SDKs
    • Signing Server
      • Installation
      • API reference
  • COMMUNITY
    • Ecosystem Programs
    • Community Libraries
    • Community Events
    • Community Channels
    • Core Contributors
  • SUPPORT
    • FAQ
      • Basic blockchain concepts
      • Ontology Nodes
      • Ontology token protocols
      • Smart contracts
      • SDKs and APIs
    • Contact Us
Powered by GitBook
On this page
  • Index
  • NewOntLoginSdk
  • GenerateChallenge
  • ValidateClientResponse
  • GetCredentialJson

Was this helpful?

  1. Decentralized Identity and Data
  2. ONT ID
  3. ONT Login
  4. Back-end Go SDK

API Reference

PreviousIntegration and UsageNextBack-end Java SDK

Last updated 2 years ago

Was this helpful?

Index

NewOntLoginSdk

Creates an OntLoginSdk instance.

Parameters

conf *SDKConfig

SDK configuration

type SDKConfig struct {
	Chain      []string                       // Supported chain, e.g."ONT","ETH","BSC"
	Alg        []string                       // Signature scheme such as "ES256","Ed25519"
	ServerInfo *modules.ServerInfo            // Server configuration info, see details below
	VCFilters  map[int][]*modules.VCFilter    // VCFilter info for authentication/authorization, see details below
type ServerInfo struct {
	Name               string `json:"name"`                             // Server name
	Icon               string `json:"icon,omitempty"`                   // Icon, optional
	Url                string `json:"url"`                              // Server URL 
	Did                string `json:"did,omitempty"`                    // Server DID, optional
	VerificationMethod string `json:"verificationMethod,omitempty"`     // Verification method, optional
}
type VCFilter struct {
	Type       string   `json:"type"`                  // Type of VC, e.g. "DegreeCredential"
	Express    []string `json:"express,omitempty"`     // List of expressions for zero-knowledge proof
	TrustRoots []string `json:"trust_roots"`           // List of trusted VC issuer DIDs
	Required   bool     `json:"required"`              // If it's required  

processors map[string]did.DidProcessor

DID processor map

nonceFunc func(int) string

Function to generate nonce

getActionByNonce func(string) (int,error)

Gets action by nonce

Returns

Field

Description

*OntLoginSdk

Instantiation successful

error

Instantiation failed

GenerateChallenge

Generates the challenge.

Parameters

type ClientHello struct {
	Ver             string           `json:"ver"`                       // Version number 
	Type            string           `json:"type"`                      // "ClientHello" for this message
	Action          int              `json:"action"`                    // 0: Authentication, 1: Authorization
	ClientChallenge *ClientChallenge `json:"ClientChallenge,omitempty"` // Challenge sent from the client for mutual authentication, optional
}

Returns

*modules.ServerHello

type ServerHello struct {
	Ver         string       `json:"ver"`                     // Version number 
	Type        string       `json:"type"`						 // "ServerHello" for this message
	Nonce       string       `json:"nonce"`                   // String of nonce
	Server      *ServerInfo  `json:"server"`                  // Server info 
	Chain       []string     `json:"chain"`                   // List of supported chains
	Alg         []string     `json:"alg"`                     // List of supported signature schemes
	VCFilters   []*VCFilter  `json:"VCFilters,omitempty"`     // List of VCFilters, optional 
	ServerProof *ServerProof `json:"ServerProof,omitempty"`   // Challenge response sent from the server for mutual authentication, optional
	Extension   *Extension   `json:"extension,omitempty"`     // Extension, optional
}

ValidateClientResponse

Validates the response from the client.

Parameters

type ClientResponse struct {
	Ver   string   `json:"ver"`					// Version number 
	Type  string   `json:"type"`				// "ClientResponse" for this message
	Did   string   `json:"did"`					// User DID
	Nonce string   `json:"nonce"`             // String of nonce generated by the server
	Proof *Proof   `json:"proof"`             // Signature info sent from the client, see details below
	VPs   []string `json:"VPs,omitempty"`     // List of verifiable presentations, optional
}
type Proof struct {
	Type               string `json:"type"`               // Signature scheme
	VerificationMethod string `json:"verificationMethod"` // DID & key index,e.g."did:ont:alice#key-1"
	Created            uint64 `json:"created"`            // Unix timestamp
	Value              string `json:"value"`              // HEX string of signature
}

Returns

Field

Description

null

Validation successful

error

Validation failed

Validation Process:

  1. Verify the validity of parameters

  2. Verify if the nonce is the same as the one generated by the server

  3. verify the signature

  4. Verify the validity of VP and VC

  5. Check if the provided VC meets the requirement

GetCredentialJson

Gets JSON string of VC from VP.

Parameters

Parameter

Description

chain

Chain name

presentation

VP string

Returns

Field

Description

[]string

JSON string of VC

error

Fail to get VC string

NewOntLoginSdk
GenerateChallenge
ValidateClientResponse
GetCredentialJson