# API Reference

## Index

* [NewOntLoginSdk](/decentralized-identity-and-data/ontid/ont-login/back-end-java-sdk/api-reference.md#newontloginsdk)
* [GenerateChallenge](/decentralized-identity-and-data/ontid/ont-login/back-end-java-sdk/api-reference.md#getcredentialjson)
* [ValidateClientResponse](/decentralized-identity-and-data/ontid/ont-login/back-end-java-sdk/api-reference.md#validateclientresponse)
* [GetCredentialJson](/decentralized-identity-and-data/ontid/ont-login/back-end-java-sdk/api-reference.md#getcredentialjson)

## NewOntLoginSdk

Creates an OntLoginSdk instance.

#### Parameters

**`SDKConfig`**

SDK configuration

```java
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
}
```

```java
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
}
```

```java
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`&#x20;

`public String genRandomNonceFunc(Integer action)`

Function to generate nonce

`@Override`&#x20;

`public Integer getActionByNonce(String nonce)`

Gets action by nonce

#### Returns

&#x20;`OntLoginSdk`

## GenerateChallenge

Generates the challenge.

#### Parameters

```java
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`

```java
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.&#x20;

#### Parameters

```java
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
}
```

```java
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&#x20;
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 &#x20;

## 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 |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ont.io/decentralized-identity-and-data/ontid/ont-login/back-end-java-sdk/api-reference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
