This is a Next.js project bootstrapped with create-next-app
.
Cryptochan is a confederated blockchain based image board that supports cryptographic signing through PGP. All threads are hashed through a standardized protocol allowing them to be recognized even when mirrored to other Cryptochan-Compatible platforms. Each platform is able to enstate their own policy regarding their operations. If you don't like my rules, then screw me! Mirror this blockchain onto your own CCC server and run it yourself!
- Cryptochan
- Environments and Policies
- Deploy
- API
GET /api/policy
GET /api/e/[hash]
GET /api/c/[cat]?page=[number]
GET /api/pk/[kid]
GET /api/pk/[kid]/t?page=[number]
GET /api/t/[hash]?page=[number]&replies=[true|false]
POST /api/regkey
POST /api/upload
POST /api/revoke
GET /api/admin
GET /api/admin/threads&page=[number]
GET /api/admin/pks&page=[number]
POST /api/admin/threads
POST /api/admin/pks
- Signing and hashing
- NEXT.JS
The config files are split between .env
and policy.ts
NEXT_PUBLIC_TITLE= # The title that will be displayed on the html
MONGO_SRV= # Link to your mongo database
S3_ENDPOINT= # The domain of your S3 provider
S3_PORT= # S3 access port
S3_ACCESS= # S3 access key
S3_SECRET= # S3 secret key
S3_PREFIX= # Prefix the S3 bucket with this string
NEXT_PUBLIC_POLICY= # Insert the policy json object generated by `yarn env`
To generate the public policy object go to scripts/generate_policy.ts
and configure the object however you wish. Then run yarn env
to have it printed as an env safe string and insert it into your NEXT_PUBLIC_POLICY=
envorinment variable.
import { IPolicy } from "./IPolicy";
export const Policy: IPolicy = {
approve_posts: true, // Posts require manual approval before joining the blockchain
publickey: {
preapproved: true, // If there is a public key, it has to have already been approved
require: true, // Public keys are required
},
embeds: ["image/webp", "video/webm"], // The mimetype of the embedded files allowed
maxEmbeds: 3, // Maximum number of embedded files
maxSize: 1e7, // Maximum size of the embedded files in bytes (currently 10MB)
maxLength: 10000 // Maximum length of the body of a thread in characters
rules: [ // Rules that will be displayed on the index page
"Rule 1",
"Rule 2",
"Rule 3",
],
categories: [ // Allowed categories, equivilant to 4chan's boards
{
name: "all",
title: "All",
description: "Welcomes all posts",
},
},
hash_algo: "SHA-256", // Default hashing algorithm
};
- Clone the repo
- Configure the environment. See .env.local
- Run
docker-compos up --build
- Clone the repo
- Configure the environment. See .env.local
- Run
npm run build
- Run
npm start
Port 5000 will open to http
Returns the policy config object provided by the env vars
Redirects to a presigned S3 url
Gets all of the top level threads of a given [cat]
egory
Gets the armored public key for a specific key id
Gets all the threads signed with that public key
Gets a thread given its hash. Set replies
to get an array of threads replying to that thread.
Register a new public key
Webform:
field | expected value |
---|---|
newkey | The armored public key up for registration |
signature | (OPTIONAL) If you wish to associate your new key with an existing key, include a detatched signature of the armored public key |
Uploads a new thread. See signing and hashing for more info
Webform:
field | expected value |
---|---|
thread | a JSON object representing a thread. [schema] |
embeds (file, multiple) | include the embedded files you wish to associate with this thread, the file name should be the hash digest of the file's binary |
Announce to the cryptochan that this public key is revoked
Webform:
field | expected value |
---|---|
public key | The new public key after it's been revoked |
Returns a PGP message containing {success: true}
encrypted for all master public keys. Used to test if a public/secret key pair is a master.
Returns a PGP message containing all threads encrypted for masters
Returns a PGP message containing all public keys encrypted for masters
Edits an existing thread. Body is a JSON object that must be signed by a master secret key.
Payloads:
{
action: "approve",
hash: string, // the hash of an existing thread
approved: boolean // is the thread approved
}
{
action: "replies",
hash: string, // the hash of an existing thread
replies: boolean // can the thread receive replies
}
Edits an existing public key. Body is a JSON object that must be signed by a master secret key.
Payloads:
{
action: "aprove",
keyid: string, // the keyid of the public key
approved: boolean // is the thread approved
}
{
action: "aprove",
keyid: string, // the keyid of the public key
"always approve": boolean // should threads signed by this key be automatically approved
}
{
action: "aprove",
keyid: string, // the keyid of the public key
master: boolean // is this key a master
}
Cryptochan follows specific guidelines for hashing, signing and verifying threads. For detail see the crypto.ts file for specific implementations.
Simply pass the raw binaries of the file into a hashing function as is.
- Construct your thread object according to this schema
- Stringify the thread using json-stable-stringify. This will ensure that the thread always gets stringified the same
- Pass the string through a hashing function
I went through some overly complicated schemes for signing threads. There's no need for complexity, simply sign the hash of the thread using your private key.
Do all of that^ in reverse.
First, run the development server:
npm run dev
yarn dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying pages/index.js
. The page auto-updates as you edit the file.
API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.js
.
The pages/api
directory is mapped to /api/*
. Files in this directory are treated as API routes instead of React pages.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.