Witness Chain
  • Introduction to Witness Chain
  • Infinity Watch
    • Proof of Location (Mainnet)
      • Introduction
      • Process flow
      • Architecture
      • Run a watchtower!
        • For Partner node runners
          • Running on Akash Cloud
          • Running on SuperNoderz
        • EigenLayer operators
          • Running a PoL Watchtower
          • Witness Chain AVS opt-in guide
        • At-home watchtowers
        • For DePIN/Validator Node provider
      • Demos
      • PoL Research
    • APIs
      • Campaign APIs
        • Key Terminologies
        • Authentication
        • Create Campaign
        • Edit campaign
        • Get Photo feed from campaign
        • Get Campaigns
      • Challenge APIs
        • Overview
        • Getting Started
  • Resources
    • Blogs
      • How Proof of Location Works
      • Redefining Geolocation Compliance: Witness Chain & Predicate
    • ๐Ÿ—ž๏ธResearch
    • ๐ŸŽ™๏ธTalks and Podcasts
    • ๐ŸคCommunity
    • โš–๏ธSmart Contracts
    • File a bug
  • Archive
    • Introduction
    • Proof of Diligence Watchtower Protocol
      • How it works
      • Diligence Watchtower Roadmap
      • Watchtower Architecture
      • Chains watched
      • Smart Contracts
      • Quick Links
      • FAQs
    • For the node operators
      • Node requirements
      • Watchtower setup
        • [ARCHIVE] Mainnet Setup
          • L2 Archive Node Setup guide
        • Holesky Setup
          • L2 Archive Node Setup guide
        • Migration from archive to full node
      • Monitoring
    • Research
    • Keys Management
    • Proof of Bandwidth
      • Introduction
      • Architecture
      • For the node operators
        • Running a PoB Challenger Client
        • Running a PoB Prover Client
      • Demos
      • Research
    • ๐ŸคWatchtower Protocol (Architecture v1)
      • ๐Ÿ—ผHow it works
      • ๐Ÿ“…Watchtower Roadmap
      • ๐ŸฆWatchtower Architecture
      • ๐Ÿ”—Chains supported
Powered by GitBook
On this page
  1. Infinity Watch
  2. APIs
  3. Campaign APIs

Authentication

PreviousKey TerminologiesNextCreate Campaign

Last updated 2 months ago

The pre-login and login APIs are crucial for the security and functionality of the Proof of Bandwidth or Proof of Location system. The APIs handles initial authentication steps, like generating session tokens and validating access. These APIs are foundational for safeguarding the prover's information and controlling system access, ensuring only authenticated users can interact with critical resources

Start the process by performing a pre-login and login requesttart the process by performing a pre-login and login request

Note: The {proof_type} parameter is crucial in all API requests and must be set to one of the following values:

  • pol (Proof of Location) -> Currently supported

  • pob (Proof of Bandwidth)

Pre-login

Login

After the result is obtained, the /login api needs to be invoked

  • POST/proof/v1/{proof_type}/pre-login
  • POST/proof/v1/{proof_type}/login
post

This API is to be called before logging in.

It will return a 'message' that has to be signed and sent to '/login' API.

This will also create a cookie;

hence the '/login' API must be called in a session.
Authorizations
Path parameters
proof_typestringRequired
Body
publicKeystringRequired

The key used for login
NOTE: when using 'ethereum' the 'publicKey = Address'
keyTypestring ยท enumRequired

The key-type of publicKey.

As of now these are supported keyTypes:
	1. solana
	2. ethereum
Possible values:
rolestring ยท enumRequired

The role the user intends to play after login:

	1. prover
		User who wants to prove what it offers to the network.

		Example: 'bandwidth', 'latency', 'disk', 'cpu' etc.

	2. challenger
		User who wants to challenge a 'prover'
		and earn rewards.

	3. payer
		An abstract entity/user who pays
		and requests for a challenge.

		A payer could be:
		the 'prover' itself, other users, or the blockchain.
Possible values:
projectNamestringOptional

If the user is also part of another blockchain project/app,

then the project-name/app-name can be provided here.

	e.g. "filecoin", "filecoin-station", "oort", etc.
projectPublicKeystringOptional

publicKey of the user associated with the

'projectName' blockchain project/app.
Responses
200
200 response
application/json
400
400 response
application/json
post
POST //proof/v1/{proof_type}/pre-login HTTP/1.1
Host: api.witnesschain.com
Cookie: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 285

{
  "publicKey": "text",
  "walletPublicKey": {
    "solana": "text",
    "ethereum": "text"
  },
  "keyType": "ethereum",
  "role": "prover",
  "projectName": "text",
  "projectPublicKey": "text",
  "claims": {
    "{claim-parameter-1}": "text",
    "{claim-parameter-2}": "text",
    "{claim-parameter-3}": "text",
    "{claim-parameter-N}": "text"
  }
}
{
  "result": {
    "message": "text"
  }
}
post

This API logs in the user.

The user should send the 'message' that was received during the '/pre-login';

and must sign the 'message' using privateKey.

And send it in the 'signature' field.
Authorizations
Path parameters
proof_typestringRequired
Header parameters
CookiestringRequired

The cookies that were received after calling '/pre-login' API.
Body
signaturestringRequired

The signature afer signing the 'message' with the 'privateKey'.

The signature can be created using MetaMask/Phantom wallet.

These signatures are generated through certain wallets/APIs.
	e.g.
    	1. Wallets in browser (Metamask / Phantom)

    	2. Dart
        		(https://pub.dev/packages/eth_sig_util)

    	3. Python
        		(https://pypi.org/project/eth-account/)

in Python it can be created as:

	from eth_account.messages import encode_defunct
	from eth_account import Account

	msg="<Message received from the pre-login response>"
	signature = sign(msg)

	def sign(msg):
	#
		# Hexadecimal key (private key)
		key = "<Your-Private-Key>"

		# Create the message hash
		msghash = encode_defunct(text=msg)

		# Sign the message
		signature = Account.sign_message(msghash, key)
		return "0x" + signature.signature.hex()
	#
Responses
200
200 response
application/json
400
400 response
application/json
401
401 response
application/json
402
402 response
application/json
post
POST //proof/v1/{proof_type}/login HTTP/1.1
Host: api.witnesschain.com
Cookie: text
Content-Type: application/json
Accept: */*
Content-Length: 20

{
  "signature": "text"
}
{
  "result": {
    "success": true
  }
}