/**
 * Participate Signing Request DTO
 */

import { IsString, IsNotEmpty, IsOptional, IsUUID, Matches } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class ParticipateSigningDto {
  @ApiProperty({
    description: 'MPC session ID',
    example: '550e8400-e29b-41d4-a716-446655440000',
  })
  @IsUUID()
  @IsNotEmpty()
  sessionId: string;

  @ApiProperty({
    description: 'Party ID',
    example: 'user123-server',
  })
  @IsString()
  @IsNotEmpty()
  partyId: string;

  @ApiProperty({
    description: 'Join token from session coordinator',
  })
  @IsString()
  @IsNotEmpty()
  joinToken: string;

  @ApiProperty({
    description: 'Message hash to sign (hex format, 32 bytes)',
    example: '0x1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890',
  })
  @IsString()
  @IsNotEmpty()
  @Matches(/^(0x)?[a-fA-F0-9]{64}$/, {
    message: 'messageHash must be a 32-byte hex string',
  })
  messageHash: string;

  @ApiPropertyOptional({
    description: 'Public key to use for signing (hex format)',
    example: '03abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab',
  })
  @IsOptional()
  @IsString()
  @Matches(/^(0x)?[a-fA-F0-9]{66}$|^(0x)?[a-fA-F0-9]{130}$/, {
    message: 'publicKey must be a valid compressed or uncompressed public key',
  })
  publicKey?: string;
}
