API Reference

Index

NewOntLoginSdk

Creates an OntLoginSdk instance.

Parameters

SDKConfig

SDK configuration

public class SDKConfig {
	String[] chain;                        // Supported chain, e.g."ONT","ETH","BSC"
    String[] alg;                        // Signature scheme such as "ES256","Ed25519"
    ServerInfo serverInfo;               // Server configuration info, see details below
    Map<Integer, VCFilter[]> vcFilters;  // VCFilter info for authentication/authorization, see details below
}
public class ServerInfo {
	String name;                    // Server name
	String icon;                    // Icon, optional
	String url;                     // Server URL 
	String did;                     // Server DID, optional
	String verificationMethod;      // Verification method, optional
}
public class VCFilter {
	String type;                    // Type of VC, e.g. "DegreeCredential"
	String[] express;               // List of expressions for zero-knowledge proof
	String[] trustRoots             // List of trusted VC issuer DIDs
	boolean required;               // If it's required  
}

Map<string,DidProcessor>

DID processor map

@Override

public String genRandomNonceFunc(Integer action)

Function to generate nonce

@Override

public Integer getActionByNonce(String nonce)

Gets action by nonce

Returns

OntLoginSdk

GenerateChallenge

Generates the challenge.

Parameters

public class ClientHello {
	String ver;                         // Version number 
	String type;                        // "ClientHello" for this message
	int action;                         // 0: Authentication, 1: Authorization
	ClientChallenge clientChallenge;    // Challenge sent from the client for mutual authentication, optional
}

Returns

ServerHello

public class ServerHello {
	String ver;                 // Version number 
	String type;		        // "ServerHello" for this message
	String nonce;              // String of nonce
	ServerInfo server;         // Server info 
	String[] chain;            // List of supported chains
	String[] alg;              // List of supported signature schemes
	VCFilter[] VCFilters;      // List of VCFilters, optional  
	ServerProof serverProo     // Challenge response sent from the server for mutual authentication, optional
	Extension extension;       // Extension, optional
}

ValidateClientResponse

Validates the response from the client.

Parameters

public class ClientResponse {
	String ver;	        // Version number 
	String type;        // "ClientResponse" for this message
	String did;         // User DID
	String nonce;       // String of nonce generated by the server
	Proof proof;        // Signature info sent from the client, see details below
	String[] VPs;       // List of verifiable presentations, optional
}
public class Proof {
	String type;            // Signature scheme
	String verificatio      // DID & key index,e.g."did:ont:alice#key-1"
	int created;            // Unix timestamp
	String value;           // HEX string of signature
}

Returns

Field

Description

null

Validation successful

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

Last updated