Merge pull request #3022 from gradido/federation-remove-getSeed

refactor(federation): remove function getSeed
This commit is contained in:
Ulf Gebhardt 2023-06-08 14:51:42 +02:00 committed by GitHub
commit e4e316a670
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,11 +8,6 @@ import { Community as DbCommunity } from '@entity/Community'
import { v4 as uuidv4 } from 'uuid'
const KEY_SECRET_SEEDBYTES = 32
const getSeed = (): Buffer | null => {
return CONFIG.FEDERATION_DHT_SEED
? Buffer.alloc(KEY_SECRET_SEEDBYTES, CONFIG.FEDERATION_DHT_SEED)
: null
}
const POLLTIME = 20000
const SUCCESSTIME = 120000
@ -32,7 +27,12 @@ type CommunityApi = {
export const startDHT = async (topic: string): Promise<void> => {
try {
const TOPIC = DHT.hash(Buffer.from(topic))
const keyPair = DHT.keyPair(getSeed())
// uses a config defined seed or null, which will generate a random seed for the key pair
const keyPair = DHT.keyPair(
CONFIG.FEDERATION_DHT_SEED
? Buffer.alloc(KEY_SECRET_SEEDBYTES, CONFIG.FEDERATION_DHT_SEED)
: null,
)
const pubKeyString = keyPair.publicKey.toString('hex')
logger.info(`keyPairDHT: publicKey=${pubKeyString}`)
logger.debug(`keyPairDHT: secretKey=${keyPair.secretKey.toString('hex')}`)